WordPress.org

Ready to get started?Download WordPress

Forums

Help Me with Dynamic H1 Titles in Header (1 post)

  1. Tranny
    Member
    Posted 2 years ago #

    Hello,

    I wanted to have the H1 title change dynamically to match the title of the page it represents, instead of arbitrarily displaying the name of the blog. I do not have much PHP experience, however I was able to get this far:

    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h1 id="site-title"><?php single_cat_title(''); ?></h1>
    <h2 id="site-description">at <a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h2>
    
    <?php /* If this is a single post */ } elseif (is_single()) { ?>
    <h1 id="site-title"><?php the_title(); ?></h1>
    <h2 id="site-description">at <a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h2>
    
    <?php /* If this is a tag */ } elseif (is_tag()) { ?>
    <h1 id="site-title"><?php single_tag_title(); ?></h1>
    <h2 id="site-description">at <a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h2>
    
    <?php /* Everything else */ } else { ?>
    <h1 id="site-title"><a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
    <h2 id="site-description"><?php bloginfo('description'); ?></h2>
    
    <?php  } ?>

    I need help adding dynamic title for pages and members (authors). Can somebody help me with that?

    Thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Topic