Support » Themes and Templates » header not displaying properly on single post (single.php) template

  • 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]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    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>

    Thanks, alchymyth! Worked like a charm.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘header not displaying properly on single post (single.php) template’ is closed to new replies.