if loop condition for widgets

Community Forums Forums General Discussion if loop condition for widgets

This topic is: not resolved

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  SoZo 1 year, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17366

    iaditya999
    Participant
    Post count: 21

    I have created two widget areas using this code…

    When widgets are added to this areas they are also showing up on blog page or anywhere.

    So how do I apply if loop condition here ??????????? And which condition to apply so they will be showing only on respective page.

    /** before content ads */
    genesis_register_sidebar( array(
    ‘id’ => ‘before content ad’,
    ‘name’ => ‘before content ad’,
    ‘description’ => ‘This is a sidebar that goes before the content and is mostly for advertising.’,
    ) );

    add_action( ‘genesis_before_post_content’, ‘child_before_content_ad_sidebar’ );
    /** Loads a new sidebar after the content */
    function child_before_content_ad_sidebar() {

    echo ‘<div class=”before content ad”>’;
    dynamic_sidebar( ‘before content ad’ );
    echo ‘</div>’;

    }

    /** after content ad */
    genesis_register_sidebar( array(
    ‘id’ => ‘after-content-ad’,
    ‘name’ => ‘After Content Ad’,
    ‘description’ => ‘This is a sidebar that goes after the content.’,
    ) );

    add_action( ‘genesis_after_post_content’, ‘child_after_content_ad_sidebar’ );
    /** Loads a new sidebar after the content */
    function child_after_content_ad_sidebar() {

    echo ‘<div class=”after-content-ad”>’;
    dynamic_sidebar( ‘after-content-ad’ );
    echo ‘</div>’;

    }

    #17424

    SoZo
    Moderator
    Post count: 1573

    For pages you use is_page(), e.g.

    [php]add_action( ‘genesis_after_post_content’, ‘child_after_content_ad_sidebar’ );
    /** Loads a new sidebar after the content */
    function child_after_content_ad_sidebar() {
    if( is_page(’1′))
    echo ‘<div class=”after-content-ad”>’;
    dynamic_sidebar( ‘after-content-ad’ );
    echo ‘</div>’;

    }[/php]
    You can learn about conditional tags here.


    John “Nicolas Flamel” Wright | SoZo’s design| John Wright Photography

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

You must be logged in to reply to this topic.