How To Make Links Only Appear On Homepage

Discussion in 'Blogging' started by banks1, Jul 7, 2009.

  1. #1
    Hi guys,

    I want to add some links to my blog http://www.FinanceAdvisoryStop.com

    I would like to add them to the sidebars. Although, I would like them to ONLY appear on the homepage, and no other pages.

    How can I do this?

    Thanks in advance!
     
    banks1, Jul 7, 2009 IP
  2. deluxdon

    deluxdon Catch Me If You Can...!!!™ Staff

    Messages:
    25,481
    Likes Received:
    1,943
    Best Answers:
    32
    Trophy Points:
    480
    #2
    Hereyou go. Add below given code in sidebar where you want link (only on homepage).

    <?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
    [B]Your Link Here[/B]
    <?php } ?>
    
    Code (markup):
    DON.
     
    deluxdon, Jul 7, 2009 IP
  3. mdvasanth86

    mdvasanth86 Notable Member

    Messages:
    3,869
    Likes Received:
    285
    Best Answers:
    0
    Trophy Points:
    230
    #3
    Yes.. Don is right.. He helped me too last time...

    Thanks don. :)
     
    mdvasanth86, Jul 7, 2009 IP
  4. banks1

    banks1 Peon

    Messages:
    1,325
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks guys, but I'm still having a little trouble. That does not seem to work. Is there some sort of widget available to do this?
     
    banks1, Jul 7, 2009 IP
  5. mdvasanth86

    mdvasanth86 Notable Member

    Messages:
    3,869
    Likes Received:
    285
    Best Answers:
    0
    Trophy Points:
    230
    #5
    <?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
    <a href="Your_link_here">Anchor-Text</a>
    <?php } ?>
    Code (markup):

    :)
     
    mdvasanth86, Jul 7, 2009 IP
  6. banks1

    banks1 Peon

    Messages:
    1,325
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I edited the sidebar.php (added that), but when I go to the homepage, no link appears.
     
    banks1, Jul 7, 2009 IP
  7. mdvasanth86

    mdvasanth86 Notable Member

    Messages:
    3,869
    Likes Received:
    285
    Best Answers:
    0
    Trophy Points:
    230
    #7
    ^^^ post the sidebar.php code here.
     
    mdvasanth86, Jul 7, 2009 IP
  8. mdvasanth86

    mdvasanth86 Notable Member

    Messages:
    3,869
    Likes Received:
    285
    Best Answers:
    0
    Trophy Points:
    230
    #8
    <?php include(TEMPLATEPATH."/config.inc.php");?>
    <div id="l_sidebar">
    
    
    [B]<?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
    <a href="Your_link_here">Anchor-Text</a>
    <?php } ?>[/B]
    
    
    <ul>
    
    <!--sidebar.php-->
    
    <?php if ( !function_exists('dynamic_sidebar')
    || !dynamic_sidebar(1) ) : ?>
    
    <!--list of categories, order by name, without children categories, no number of articles per category-->
    <li>
    <h3>Categories</h3>
    <ul>
    <?php $params = "orderby=name&title_li&exclude=" . $np_feature_cat . "," . $np_sidenotes_cat . "," . $np_pop_cat; ?>
    <?php wp_list_categories($params); ?>
    </ul>
    </li>
    
    <li>
    <h3>Archives</h3>
    <ul>
    <?php wp_get_archives('type=monthly&limit=12'); ?>
    </ul>
    </li>
    
    <!--Ad Unit-->
    <li>
    <img src="<?php bloginfo('template_url'); ?>/images/ad.png"></img>
    </li>
    
    <?php endif; ?>
    </ul>
    </div>
    Code (markup):



    I think this should work.
     
    mdvasanth86, Jul 7, 2009 IP