I’m trying to show the by-line of a WordPress post only when it’s a named author. I don’t want to show the byline of the admin user.
Here’s the code I’m using to attempt this:
<?php if (get_the_author() != 'admin')?>
<h3 style="font-style:italic;">by <?php the_author(); ?></h3>
<?php endif;?>
The behavior I’m seeing, but don’t want, is that the page hangs up and displays only the header. It’s only when I comment out the two php lines that the h3 content shows.
I’ve verified that the full string that would make the condition be true is exactly what I’m showing above. I copy/paste it from the view source of the rendered page. I’ve even tried using the number 1 both as an integer and as a character type for the test, but it still hangs the page.
What might I be doing wrong? Am I understanding this correctly?
Your problem, where the “page hangs up” is one of syntax. You are missing a
:
after yourif
statement:This should fix it:
This is the kind of error that is easily detectable by enabling
error_reporting
and checking your logs, or enablingdisplay_errors
as well: