How to remove widget on POSTS only

Community Forums Forums Design Tips and Tricks How to remove widget on POSTS only

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  stephencounsell 1 year, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #17026

    stephencounsell
    Participant
    Post count: 15

    Hi,

    I’m building my first child theme based on the “Simple Example” child theme and have a problem with the sidebar widget apearing on every page.

    The registered sidebar contains a Responsive Slider widget that should appear ONLY on the home page.

    the URL for the test site is: http://1063991394.1055256391.temp.prositehosting.co.uk

    I have managed to remove the slider from all “Pages” but it still shows on “POSTS”

    Here is the rather in-ellegant way id did that:

    <code>

    add_action( ‘genesis_before_content’, ‘widget_title’ );
    function widget_title() {
    $pagename = get_query_var(‘pagename’);
    if($pagename==””){
    echo ‘<div class=”widget_title”>’;
    dynamic_sidebar( ‘widget_title’ );
    echo ‘</div>’;

    }

    }

    </code>

    This essentially looks for a page with a null value for the page name.

    I’m sure I’ve got something wrong here so I really need some help on this.

     

    Thansk

    Steve

    #17031

    stephencounsell
    Participant
    Post count: 15

    OK, So I was watching Studiopress.TV and found the answer. Well at least one that works for me…

    In addition to the coded IF staement I use the (Not Single) code like this

    if($pagename==”” && !is_single()) – Note the && means “AND” and the ! means “NOT”

    Cheers

    Steve

    #17032

    braddalton
    Participant
    Post count: 10356

    This tutorial contains multiple variations for creating widgets including conditional tags which is what you need. http://designsbynickthegeek.com/tutorials/add-widgeted-sidebar

    You ‘ll need the correct conditional http://codex.wordpress.org/Conditional_Tags


    #17033

    stephencounsell
    Participant
    Post count: 15

    Hey Brad, Thanks loads for that. I’m gonna need all the help I can get….

    Regards

    Steve

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.