pre_get_posts exclusion of groups rule has stopped working
-
This function used to ensure, that titles of group “hidden” post were still shown on archives and front page here: aktieraadet.dk to tease the reader. And then when they clicked the link, they were forced to log in, or buy the access rights. Now only open (not group restricted) post are shown. I haven’t noticed when this happened. But got a complaint about it a couple of weeks ago.
// 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_home() || 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 ); } }
I did a writeup about it a couple of years ago here: https://woocommerce.com/2015/03/customer-story-paid-newsletter-subscriptions-with-woocommerce/ back then the snippet worked like a charm. Any thoughts on what happened, or what could fix it would be greatly appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘pre_get_posts exclusion of groups rule has stopped working’ is closed to new replies.