Skip to content

Instantly share code, notes, and snippets.

@rheinardkorf
Last active November 2, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rheinardkorf/f6457a76790cda79d004 to your computer and use it in GitHub Desktop.
Save rheinardkorf/f6457a76790cda79d004 to your computer and use it in GitHub Desktop.
Remove Pro Sites Ad modules from given pages/posts - This snippet is used to prevent ads from showing up on the front end for given pages or post types on your site.
<?php
// ---------------------------------------------
// Remove this line and up if you're adding it to an existing PHP file
// Add this to a theme's functions.php file or a custom plugin.
// This will precent the ads from showing on certain pages on your site
function 20151102_remove_ads_on_page ( $setting, $default ) {
// Option 1 -- Filter by page IDS specified as array
// Replace with specific page IDS
$page_ids = array(
111,
123,
88
);
if( is_page() ) {
if( in_array( get_the_ID(), $page_ids ) ) {
$setting = false;
}
}
// Option 2 -- Filter by post type specified in array
global $post;
// Replace with specific post types
$post_types = array(
'my_custom_type',
'faq_post_type'
);
if( is_page() ) {
if( in_array( get_post_type( $post ), $post_types ) ) {
$setting = false;
}
}
return $setting;
}
add_filter( 'psts_setting_ads_before_page', '20151102_remove_ads_on_page', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment