• Resolved sk160770

    (@sk160770)


    I want to display different widgets on different pages of my site. For example I do not want to show ads on my homepage, instead I would like to show Most Popular posts, while, on the same place, ads on other pages eg. posts, category or archive.
    I think it can be achieved using Conditional Statement (If….Then) but I am unable to figure out how to do this with widgets ?

    Anybody used conditional statements with widgets before ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • There are three ways to do it with widgets

    1]Use raw PHP in the widget itself, which will allow you to use the is_home() conditional tag

    2]Edit your functions.php file and add all widgets through conditional tags. You will need the widget ID for such filtering. This might be easier to edit the widgets.php itself which is the third way

    3]When you open widgets.php you will find a list of all installed widgets something like this :

    <?php include(TEMPLATEPATH . ‘/includes/widgets/widget-about.php’);
    include(TEMPLATEPATH . ‘/includes/widgets/widget-adsense.php’);
    include(TEMPLATEPATH . ‘/includes/widgets/widget-ads.php’);
    ?>

    You can add your conditional tags there.

    or, try a plugin like dynamic widgets.

    Thread Starter sk160770

    (@sk160770)

    Thank you buddies for your kind help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Different widgets on different pages’ is closed to new replies.