• Resolved hs1972

    (@hs1972)


    Is there a checkbox to block ads on all pages, but not posts? I know I can go into each one individually but just wondered if there was a way to do en-masse

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Thomas Maier

    (@webzunft)

    Hi hs1972,

    thanks for reaching out.

    There is no general option for this, yet. You could use the many hooks to accomplish something like that. If you aren’t a coder but comfortable copy&pasting code I might be able to send you an example of one that would completely disable ads from non-posts.

    Thomas

    Thread Starter hs1972

    (@hs1972)

    Hi Thomas

    Thanks for getting back to me. I can code (only a little) so I’d be happy to copy and paste if there is anything that you have to hand?

    Thanks
    Helen

    Plugin Author Thomas Maier

    (@webzunft)

    Hi Helen,

    you can use the advanced-ads-can-display hook to remove ads from non-posts. I quickly wrote and tested the following code, but please test it carefully.

    It goes into the functions.php of your theme.

    add_action( 'advanced-ads-can-display', 'advads_show_ads_on_posts_only' );
    function advads_show_ads_on_posts_only( $can_display ){
        
        global $post;
        
        if( ! isset( $post->post_type ) || 'post' !== $post->post_type ){
    	return false;
        }
        
        return $can_display;
    }

    For future reference, most hooks are documented here.

    Thomas

    • This reply was modified 6 years, 7 months ago by Thomas Maier.
    • This reply was modified 6 years, 7 months ago by Thomas Maier.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Block ads on all pages (not posts)’ is closed to new replies.