Answer the question
In order to leave comments, you need to log in
How to exclude received posts from the main cycle for registered users?
Greetings!
How can I exclude posts from the main loop (index.php) that I get from the Favorite Post plugin?
I get bookmarked posts from the plugin like this:
$favorites = WeDevs_Favorite_Posts::init()->get_favorites();
<?php
if ( have_posts() ) :
/* Start the Loop */
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );
endwhile;
the_posts_navigation();
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
Answer the question
In order to leave comments, you need to log in
He asked, answered himself)
did this:
$favorites = WeDevs_Favorite_Posts::init()->get_favorites(); // Get posts
$post_ids = wp_list_pluck( $favorites, 'post_id' ); // Collect into an array with ID
query_posts(array( 'post__not_in' => $post_ids )); // Exclude from the loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question