Hi
Thanks for a great theme. I have used it several times. But I have a little issue I hope you can solve.
I am using the builder on all posts. At the end of a post I use the blog post element to show related/more posts. Is it possible to remove the current post from the blog post element (using grid view)? At the moment it is showing the same post as you are reading. This does not look that professional so it would be great if it could be filtered out somehow – maybe with a function?
Kind regards,
Michael
Hey Michael,
Thanks for contacting us!
Please edit your Blog Posts element and go to Filter > Offset Number and choose not to allow duplicate posts – https://imgur.com/a/2KEGYqC? :)
Cheers!
Yigit
Hi Yigit
It does not seem to be working. The first post in the bottom of the page is still the same as the one you are reading. I would like to exclude the current post from the blog post element. It should chose 3 other post and exclude the current one.
Hope this can be solved.
Kind regards,
Michael
try this in your child-theme functions.php:
function ava_exclude_current_post($query) {
if (is_singular('post') || is_singular('portfolio') ) {
$exclude = avia_get_the_ID();
$query->set( 'post__not_in', array($exclude) );
}
}
add_action('pre_get_posts', 'ava_exclude_current_post');
or maybe shorter to use as condition above:
if(is_single()){
Hi Guenni
Thanks a lot for the code. That seems to do the trick :)
Kind regards,
Michael
Hi,
Glad Guenni007 could help, thank you Guenni007, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.
Best regards,
Mike