Skip to content

Instantly share code, notes, and snippets.

@Wysija
Created November 17, 2014 15:57
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 Wysija/a5eca247c526445ddb2c to your computer and use it in GitHub Desktop.
Save Wysija/a5eca247c526445ddb2c to your computer and use it in GitHub Desktop.
Show teaser content to non members for the plugin Groups. Add the code to your theme's functions.php
// Show title, excerpt and thumbnail in archives
add_action('pre_get_posts', 'my_pre_get_posts');
function my_pre_get_posts() {
// If the user is looking at the front page
if ( is_archive() || is_category() || is_front_page() ) {
// Remove the Groups_Post_Access filters
remove_filter( 'posts_where', array( 'Groups_Post_Access', 'posts_where' ), 10, 2 );
remove_filter( 'the_posts', array( 'Groups_Post_Access', 'the_posts' ), 1, 2 );
remove_filter( 'get_the_excerpt', array( 'Groups_Post_Access', 'get_the_excerpt' ), 1 );
remove_filter( 'the_content', array( 'Groups_Post_Access', 'the_content' ), 1 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment