Changing WORDPRESS header, to post/page title EXCEPT homepage -something to do with header.php file

9 replies
  • WEB DESIGN
  • |
I'm tryh3ing to change my heading...in wordpress which is the <h3> tag.

I went into the header.php file of the theme editor and I found something that works...but it changes the header on the homepage to the most recent post title...which I don't want of course.

Anyways, I went into the file and found this....

<h3><a href="<?php echo get_option('home'); ?>/">
<?php bloginfo('name'); ?>
</a></h3>
<p class="tagline">
<?php bloginfo('description'); ?>
</p>


I changed...
<?php bloginfo('name');?>

to this...
<?php the_title(); ?>


so after the change, it looks like this

<h3><a href="<?php echo get_option('home'); ?>/">
<?php the_title(); ?>
</a></h3>
<p class="tagline">
<?php bloginfo('description'); ?>
</p>


Now that DID change the header to the post/page title for all individual posts and pages...

HOWEVER, I want the homepage header to still be the title of the website, but instead it changes it to the most recent post made, rather than the website title.

Any help would be appreciated.
#changing #header #post or page #title #wordpress
  • Profile picture of the author Adam Roy
    Do you have any suggestions as to how to do this?
    {{ DiscussionBoard.errors[2511816].message }}
  • Profile picture of the author tyankee
    Originally Posted by friend View Post

    I'm tryh3ing to change my heading...in wordpress which is the <h3> tag.

    I went into the header.php file of the theme editor and I found something that works...but it changes the header on the homepage to the most recent post title...which I don't want of course.

    Anyways, I went into the file and found this....

    <h3><a href="<?php echo get_option('home'); ?>/">
    <?php bloginfo('name'); ?>
    </a></h3>
    <p class="tagline">
    <?php bloginfo('description'); ?>
    </p>


    I changed...
    <?php bloginfo('name');?>

    to this...
    <?php the_title(); ?>


    so after the change, it looks like this

    <h3><a href="<?php echo get_option('home'); ?>/">
    <?php the_title(); ?>
    </a></h3>
    <p class="tagline">
    <?php bloginfo('description'); ?>
    </p>


    Now that DID change the header to the post/page title for all individual posts and pages...

    HOWEVER, I want the homepage header to still be the title of the website, but instead it changes it to the most recent post made, rather than the website title.

    Any help would be appreciated.

    not sure of the syntax but sounds like you need a simple if then else clause:

    if(is_home())
    bloginfo('name')
    else
    the_title()
    endif

    of course this is not the correct syntax but i'm sure you can figure it out..

    and as for the comment about not touching PHP files, not sure where that comes from as i've been changing and having programmers change PHP files successfully for years - 99% in the themes files of course.
    {{ DiscussionBoard.errors[2512020].message }}
  • Profile picture of the author Adam Roy
    That looks like what I'm looking for...however I have NO IDEA how to incorporate that into the php file.

    Any advice? The example I used above is the EXACT code copy and pasted from the header.php file so if you can help me change it using the above I'd really...really appreciate it.
    {{ DiscussionBoard.errors[2512544].message }}
    • Profile picture of the author tyankee
      Originally Posted by friend View Post

      That looks like what I'm looking for...however I have NO IDEA how to incorporate that into the php file.

      Any advice? The example I used above is the EXACT code copy and pasted from the header.php file so if you can help me change it using the above I'd really...really appreciate it.

      try this - but i'm about a 'C' grade PHP guy so i'm not sure if it will work:


      replace - <?php bloginfo('name'); ?> with:
      <?php if (!is_home())
      { bloginfo('name'); }
      else { the_title(); }
      ?>

      i do most of my PHP by trial and error - so play around with that if it doesn't work.
      {{ DiscussionBoard.errors[2512734].message }}
      • Profile picture of the author mrmagos
        What tyankee posted should work, but his syntax (as you found) was slightly off. Try this:
        PHP Code:
        <?php if (!is_home()) 
        {   
        bloginfo('name'); 
           else  { 
        the_title(); }
        ?>
        {{ DiscussionBoard.errors[2533195].message }}
  • Profile picture of the author Adam Roy
    That didn't do it. Brought up a syntax error
    {{ DiscussionBoard.errors[2532801].message }}
  • {{ DiscussionBoard.errors[2534952].message }}
  • Profile picture of the author mrmagos
    Fine, let's try the alternate syntax (I prefer this - I tend to miss closing fewer tags this way) and changing the order of the statement.
    PHP Code:
    <?php if ( is_home() || is_front_page() ) :
      
    bloginfo('name');
      else :
      
    the_title();
    endif; 
    ?>
    What theme are you using?
    {{ DiscussionBoard.errors[2535950].message }}
  • Profile picture of the author Adam Roy
    THAT'S IT!!!!!

    Wahoooooooooooooooooooooo.

    I wish I could give you like 10 thanks.
    {{ DiscussionBoard.errors[2536648].message }}

Trending Topics