I’m using this code with success on some wordpress installation, but with my new theme it doesn’t work.
<?php echo is_home() ? '<h1>' : '<h2>'; ?>
<a href="<?php echo home_url(); ?>/">
<?php bloginfo('name'); ?>
</a>
<?php echo is_home() ? '</h1>' : '</h2>'; ?>
On this website I have a static page as front page which might be the reason of it not working.
I’m not so good with PHP so any help would be appreciated. I guess if i call the page name instead of home it might work but not sure about the syntax
Thanks!
Try changing is_home() to is_front_page() , that should sort it.
What are you trying to do with this code? What part isnt working? Is it the ternary operator not displaying h1/h2 or are the php functions not printing out the right information?
Shouldn’t all page titles use H1? What do you put in the H1 on the “other pages”?
If you put the Website Title in there, you might reconsider doing that. Because a site title should not be H1. This is because Google sees all you pages having the same H1 tag which has a negative result on your page rank in Google.