WordPress.org

Ready to get started?Download WordPress

Forums

header not displaying properly on single post (single.php) template (3 posts)

  1. Benjamin
    Member
    Posted 2 years ago #

    Hello everyone,

    I'm currently editing a WordPress template to fit my needs, and I'm running into one small, but annoying, issue. I have my blog title as an <h1> tagged element on every template of the blog (home page, search results, author page, etc.), but the <h1> tag doesn't seem to be rendering properly on the "single post" (single.php) template. The header.php template is rendering properly on the page, but the text size is not correct (see benleetaylor.com/blog vs. http://benleetaylor.com/blog/?p=1). Does anyone have any idea why this would be? I have included the code from both the single.php and header.php templates below. Thanks.

    header.php

    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <title><?php wp_title(' | ', true, 'right'); ?><?php bloginfo('name'); ?></title>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" />
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>
    </head>
    <body <?php body_class(); ?>>
    <div id="wrapper" class="hfeed">
    <div id="header">
    <?php if ( is_singular() ) {} else {echo '<h1>';} ?><a href="<?php echo home_url() ?>/" title="<?php bloginfo( 'name' ) ?>" rel="home"><?php bloginfo( 'name' ) ?></a><?php if ( is_singular() ) {} else {echo '</h1>';} ?>
    <h2 id="blog-description"><?php bloginfo( 'description' ) ?></h2>
    <div id="nav">
    <?php wp_nav_menu( array( 'menu' => 'navbar' ) ); ?>
    </div>
    </div>

    single.php

    [code moderated per forum rules - please use the pastebin for any code longer than 10 lines]

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    this line in header.php:

    <?php if ( is_singular() ) {} else {echo '<h1>';} ?><a href="<?php echo home_url() ?>/" title="<?php bloginfo( 'name' ) ?>" rel="home"><?php bloginfo( 'name' ) ?></a><?php if ( is_singular() ) {} else {echo '</h1>';} ?>

    only adds the h1 tag to pages that are not singular, i.e. not to single posts and single static pages.

    change to:

    <h1><a href="<?php echo home_url() ?>/" title="<?php bloginfo( 'name' ) ?>" rel="home"><?php bloginfo( 'name' ) ?></a></h1>
  3. Benjamin
    Member
    Posted 2 years ago #

    Thanks, alchymyth! Worked like a charm.

Topic Closed

This topic has been closed to new replies.

About this Topic