WordPress.org

Support

Support » Themes and Templates » [Resolved] Want to show different H1 title on homepage

[Resolved] Want to show different H1 title on homepage

  • Christopher Roberts
    Member

    @christopherrobertswordpress

    Hi everyone. I am part of a Community Blog called Technology Bloggers, and in order to get Google+ buttons to work the way I want them to, on the homepage, I need this title code to show

    <span itemprop="name" content="Technology Bloggers"></<?php echo $heading_tag; ?>></span>

    Whilst on the rest of the site, only want the standard
    </<?php echo $heading_tag; ?>>
    to show.

    I have tried adding this code to the header.php file, but it just kills the site (site doesn’t load, just a blank page, suggesting code error)

    <?php
    if ( is_front_page() ) {
    <span itemprop="name" content="Technology Bloggers">
    				</<?php echo $heading_tag; ?>>
    </span>
    } else {
    				</<?php echo $heading_tag; ?>>
    }
    ?>

    I only want the code to show on the front page of the blog, not on page 2, archives, posts etc. just the very front page.

    any ideas/help?

    Thanks guys
    Christopher

Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael
    Forum Moderator

    @alchymyth

    echo $heading_tag; is possibly not what you think – it is part of the closing html tag of the site title, conditionalyl changed depending on what page your are on.

    please paste the full code of header.php into a pastebin and post the link to it here – HOW-TO .

    Christopher Roberts
    Member

    @christopherrobertswordpress

    Okay, change of plan slightly. In header.php, I want to add these meta tags:

    <meta itemprop="name" content="Technology Bloggers">
    <meta itemprop="description" content="Technology Bloggers - a dofollow community technology blog!">
    <meta itemprop="image" content="http://www.technologybloggers.org/images/Technology-Bloggers-Logo.jpg">

    however I only want them to appear on the front page. Literally just that 1 page.

    Here is header.php
    http://pastebin.com/CmzrZDhV

    Any ideas?

    Michael
    Forum Moderator

    @alchymyth

    wrap the meta into a conditional statement, using is_home() and is_paged() or is_front_page()

    http://codex.wordpress.org/Conditional_Tags

    if you are using a static front page, use:

    <?php if( is_front_page() ) : ?>

    if the posts page is on the front, use:

    <?php if( is_home() && !is_paged() ) : ?>

    for example (posts on front), in line 84 of the pastebin code, add:

    <?php if( is_home() && !is_paged() ) : ?>
    <meta itemprop="name" content="Technology Bloggers">
    <meta itemprop="description" content="Technology Bloggers - a dofollow community technology blog!">
    <meta itemprop="image" content="http://www.technologybloggers.org/images/Technology-Bloggers-Logo.jpg">
    <?php endif; ?>
    Christopher Roberts
    Member

    @christopherrobertswordpress

    Brilliant, works a treat, thanks 🙂

    Im having an issue trying to change the site title to only one page. I tryed creating a new header.php Iv created (copied my theme default header) but I cant seem to understand where in it do I change the actual code?

    say I want to have on that specific the site title “MAIN”

    Also how do I use an actual html code directly meaning without ‘calling’ every part of the page? (Im using a custom template)

    Andrew Nevins
    Forum moderator

    @anevins

    If you’ve tried the solutions in this thread and cannot resolve the issue, it is more likely your issue is different.

    Try creating a thread to discuss your issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Want to show different H1 title on homepage’ is closed to new replies.