WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Want to show different H1 title on homepage (7 posts)

  1. Christopher Roberts
    Member
    Posted 2 years ago #

    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

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    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 .

  3. Christopher Roberts
    Member
    Posted 2 years ago #

    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?

  4. alchymyth
    Forum Moderator
    Posted 2 years ago #

    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; ?>
  5. Christopher Roberts
    Member
    Posted 2 years ago #

    Brilliant, works a treat, thanks :-)

  6. dyangrey
    Member
    Posted 1 year ago #

    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)

  7. Andrew
    Forum Moderator
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic