• Hi,

    I am using a Genesis child theme.

    I am using a widget in a Genesis child theme to display Adsense under post tile but I need to exclude it from two posts.

    Here’s the code (this creates the widget where I just paste the AdSense code.

    //* New Widget area to show ads under post title
    genesis_register_sidebar( array(
        'id'                => 'ad-after-title',
        'name'          => __( 'Ad After Title', 'custom' ),
        'description'   => __( 'This is Ad section under post title', 'custom' ),
    ) );
     
    //* Show ads below post title on posts
    add_action( 'genesis_entry_header', 'mp_post_ad_feature', 12 ); 
    function mp_post_ad_feature() {
        if ( is_single() && is_active_sidebar( 'ad-after-title' ) ) {
        echo '<div class="ad-after-title">';
        dynamic_sidebar( 'ad-after-title' );
        echo '</div><!-- end .ad-after-title -->';
        }
    }
    

    I have used this snippet

    if(is_single( array('post1-url', 'post2-url'))):  
    else:

    in another code where the && is_active_sidebar isn’t used. so I am not sure how and where to place the little snippet, or if there is any other way.

    I would appreciate any help. Thank you very much in advance.

    • This topic was modified 3 years, 3 months ago by satrap.
    • This topic was modified 3 years, 3 months ago by satrap.
    • This topic was modified 3 years, 3 months ago by satrap.
    • This topic was modified 3 years, 3 months ago by satrap.
Viewing 3 replies - 1 through 3 (of 3 total)
  • //* Show ads below post title on posts
    add_action( 'genesis_entry_header', 'mp_post_ad_feature', 12 ); 
    function mp_post_ad_feature() {
        if(is_single( array('post1-url', 'post2-url'))) {
            return;   // do nothing
        }
        if ( is_single() && is_active_sidebar( 'ad-after-title' ) ) {
             // show sidebar
             echo '<div class="ad-after-title">';
             dynamic_sidebar( 'ad-after-title' );
             echo '</div><!-- end .ad-after-title -->';
        }
    }
    Thread Starter satrap

    (@satrap)

    Alan, thank you very much for taking time out of your busy day to help without anything in return.

    Your code worked perfectly.

    Thank you so very much again. Have a great day.

    Glad you got it sorted.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excluding AdSense from specific post in Genesis child theme’ is closed to new replies.