[ASK] how to make my widget only shown on homepage?

Discussion in 'WordPress' started by gethqlinks, Dec 22, 2011.

  1. #1
    Hi,

    I'd like to have a widget that can be seen on homepage only,

    could someone please help me how to this?
     
    gethqlinks, Dec 22, 2011 IP
  2. lamvt

    lamvt Active Member

    Messages:
    153
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    need to check you home-page.php file in your themes and add position to show just your widget only.
     
    lamvt, Dec 22, 2011 IP
  3. Sensei.Design

    Sensei.Design Prominent Member

    Messages:
    3,847
    Likes Received:
    162
    Best Answers:
    0
    Trophy Points:
    310
    Digital Goods:
    1
    #3
    It's pretty easy all you need to do before you include the widget is use this check

    
    <?php
    if ( is_home() ) {
        // This is a homepage
    } else {
        // This is not a homepage
    }
    ?>
    
    Code (markup):
    of course you will need a second widget area that will displayed on all pages ;)
     
    Sensei.Design, Dec 23, 2011 IP
  4. Pradosh

    Pradosh Peon

    Messages:
    87
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Pradosh, Dec 24, 2011 IP
  5. gethqlinks

    gethqlinks Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Wow.. these are very helpful, thanks for all the advise guys :)
     
    gethqlinks, Jan 2, 2012 IP
  6. prince@life

    prince@life Notable Member

    Messages:
    278
    Likes Received:
    13
    Best Answers:
    3
    Trophy Points:
    225
  7. KarenKramer

    KarenKramer Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I use the free plugin "Widget Context". It allows me to determine which pages I want the widget content to show up on.
     
    KarenKramer, Jan 4, 2012 IP
  8. TechnoKiD

    TechnoKiD Peon

    Messages:
    10
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Widget Context is the best option when you don't want to mess around with theme files and php codes.. got for it... hope it helps.. good luck
     
    TechnoKiD, Jan 5, 2012 IP
  9. Yojance

    Yojance Greenhorn

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #9
    I've always used the following when you create a page and set it as the Home Page.

    if( is_front_page() ) {
        dynamic_sidebar('front-page-sidebar');
    } else {
        dynamic_sidebar('other-sidebar');
    }
    PHP:
     
    Yojance, Jan 5, 2012 IP