Need wordpress help to show links ONLY on homepage (and in sidebar)

Discussion in 'WordPress' started by Nichemasterflex, Dec 13, 2009.

  1. #1
    hey there,

    I need to customize a few wordpress themes so that I can show the sidebar resource links ONLY on the homepage..

    I managed to do it for one of my sites but can't figure my other themes out.

    here's the code I've been using:

    <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>

    <li><a href="http://www.exampleurl.com/" target="_blank"
    >Example Anchor Text</a></li>

    <?php } ?>

    but when I post it under the text widget it still appears sitewide so I must be missing something..

    any help would be muchly appreciated.. even willing to pay a few bucks <$20 for someone to help me with this across my blog network.. pm me for more details or if you have the answer quick post and ill help you out with some rep points or a free link off one of my sites..
     
    Nichemasterflex, Dec 13, 2009 IP
  2. Cartman

    Cartman Active Member

    Messages:
    354
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    88
    #2
    Try this:

    
    <?php if ($_SERVER["REQUEST_URI"] == "/" || $_SERVER["REQUEST_URI"] == "/index.php") { ?>
    
    <li><a href="http://www.exampleurl.com/" target="_blank"
    >Example Anchor Text</a></li>
    
    <?php } ?>
    
    Code (markup):
    I use this on my Wordpress blogs, and it works great.

    I've used your code before, but that still shows ads on Page 2, Page 3, etc. (It does prevent the ads from showing up on actual post pages though)

    Hope this helps!
     
    Cartman, Dec 13, 2009 IP
  3. Nichemasterflex

    Nichemasterflex Active Member

    Messages:
    398
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    hmm.. thanks for that.. but doesnt seem to work with my theme when i put it in either the sidebar or under the text widget either.. any other suggestions?
     
    Nichemasterflex, Dec 13, 2009 IP
  4. theapparatus

    theapparatus Peon

    Messages:
    2,925
    Likes Received:
    119
    Best Answers:
    0
    Trophy Points:
    0
    #4
    theapparatus, Dec 13, 2009 IP
  5. Nichemasterflex

    Nichemasterflex Active Member

    Messages:
    398
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #5
    yeah.. I used the front page code for my other site and it worked, as for second point - it didn't work meaning it was still showing the link on all the pages, not just the homepage..

    plus it's a different style formatting so I would prefer to have it in the sidebar..

    <div class="sidebar_container">
    <h2>Resources</h2>
    <ul>
    <?php wp_list_bookmarks('categorize=0&title_li='); ?>
    </ul>
    <div class="sidebar_bottom"></div>
    </div>
    <?php endif; ?>

    is an example of how the formatting & style of this specific theme.. doesn't seem to be a universal code that works across different themes .. so how would I change this one? I'm not a programmer so I have no idea... lol
     
    Nichemasterflex, Dec 13, 2009 IP
  6. theapparatus

    theapparatus Peon

    Messages:
    2,925
    Likes Received:
    119
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Please provide us with a link or what you're seeing

    "it didn't work meaning it was still showing the link on all the pages, not just the homepage.. " is not specifics. It's a general statement.

    If you need us to look at the css formating, we need to be able to see the outputted code.

    Thanks
     
    theapparatus, Dec 13, 2009 IP
  7. Nichemasterflex

    Nichemasterflex Active Member

    Messages:
    398
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #7
    Nichemasterflex, Dec 13, 2009 IP