“Post Carousel” update – Remove post from carousel
-
Hello.
Please add the opportunity to remove a specific post from the carousel by ID in “Post Carousel”, or to remove the post from the carousel where this carousel works.-
This topic was modified 5 years, 11 months ago by
Shmanich.
-
This topic was modified 5 years, 11 months ago by
-
I agree this would help a lot to be able to restrict by tags or category or ID
Hello @johnnyfraisse,
You can use the offset parameter in the wp_query function to exclude the latest posts from the WordPress post loop. You can collect all posts IDs in an array in the first loop, and excluded those posts from the second loop using
post__not_inwhich expects an array of post IDs.
You can use the following filter in your child theme’s functions.php file:function filter_post_query( $query_args, $attributes) { // Modify $query_args values. // 123 is the post id you want to exclude. $query_args['post__not_in'] = array( 123,456 ); return $query_args; } add_filter( 'uagb_post_query_args_grid', 'filter_post_query', 10, 2 );In the above code, the array (123, 456), the 123 and 456 in the post ID which you want to exclude.
I hope this helps. Let me know if you have further queries.Regards,
Sweta@brainstormteam,
I have 10 posts (called “Teachers”) and inserted the “post carousel” in each of them so that they display other teachers under each post. For example, post “John Smith”, description, below the description of “post carousel other teachers”, where the current post is excluded from. And in the second post, a different teacher, so John Smith should appear in “post carousel”.@brainstormteam, hello.
I’d better show here what I would like to add to the “post carousel”.
There are several posts about teachers on my site:
https://yadi.sk/i/4KtP3BovNyXq5gThere is a “post carousel” that serves as links to other posts:
https://yadi.sk/i/0ggXmXJ70mwsPg
https://yadi.sk/i/PFD125FsA248hgBut in the “post carousel” comes across a link to a post that is already open. He is superfluous in the carousel:
https://yadi.sk/i/Q2zcV78ORo0VngTherefore, I ask you to add the ability to exclude such posts or by ID in the “post carousel”.
Hello @shmanich,
I’m so sorry for the inconvenience caused to you. You can exclude posts from the Post Carousel block using the following filter.
To do that please follow the following steps:-
- To apply different filters for a specific block you need to add a unique class to the block from the Advanced Tab of Post Carousel Block.
- You need to get the post IDs of the Pages or Posts you want to exclude.
- After that, you need to add the following filter in your child theme’s functions.php file.
function filter_post_query( $query_args, $attributes) { // Unique class name added from Advanced tab for Post Carousel. if ( 'my-post-grid-class' == $attributes['className'] ) { // 123 and 456 is the post id you want to exclude. $query_args['post__not_in'] = array( 123,456 ); } return $query_args; } add_filter( 'uagb_post_query_args_carousel', 'filter_post_query', 10, 2 );I hope this helps.
Regards,
Sweta-
This reply was modified 5 years, 11 months ago by
Team Brainstorm Force.
@brainstormteam, your code didn’t help me. 🙁
Please add filtering to “Post Carousel” settings.Hello.
After a recent update, it was possible to remove the current post in “Post Carousel”. Thank!
Screenshot: https://yadi.sk/i/TU1InONXKz05lgYes, @shmanich ! 🙂
If you need any further help, please do let us know.
Здравствуйте.
Добавьте теперь возможность удалить конкретную запись из карусели по идентификатору записи в «Карусель постов».
The topic ‘“Post Carousel” update – Remove post from carousel’ is closed to new replies.