Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.