Keep semantics by wrapping the title in H1 when it makes sense
Sometimes it makes sense to start your page with the company title in H1 tag. But in case of a single blog post, having that post's title in H1 and the company title in DIV would make much more sense.
We can use Wordpress conditional tags to achieve this.
From header.php:
<?php
/**
* Page title in H1 when it makes sense, DIV otherwise
*/
$logo_tag = 'div';
if(is_front_page()) {
$logo_tag = 'h1';
}
?>
<header>
<<?php echo $logo_tag; ?> id="logo">
<a href="<?php echo home_url("/"); ?>" rel="home"><?php bloginfo('name'); ?></a>
</<?php echo $logo_tag; ?>>
</header>Written by Andrej Čremožnik
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Did you know?
WordPress sites collect scripts from themes, plugins, and tag managers. A compromised plugin update can add a skimmer to every page without a change in your own templates.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#