We use the Masonry element to display thumbnails of portfolio posts on a portfolio post filtered by category. It is like looking at one product description and showing at the bottom of the post related products of the same category. Works fine, but we would like to show only OTHER portfolio items of the same category hide the one we are already looking at. Any idea how to do that?
You can see it online here and at the bottom of the portfolio post you see the other portfolio posts within the same category. We like to avoid that the “Romantic Venice …” one is shown on itself. It is kind of recursive.
Hey milano24ore,
Thank you for the inquiry.
hide the one we are already looking at. Any idea how to do that?
It is possible to exclude the current post from the related section or from the Masonry element. You can use this filter in the functions.php file.
function avia_masonry_entries_query_mod($query, $params)
{
if(is_singular('portfolio')) {
$query['post__not_in'] = array(avia_get_the_ID());
}
return $query;
}
add_filter('avia_masonry_entries_query','avia_masonry_entries_query_mod', 10, 2);
Best regards,
Ismael
Hi Ismael,
You are the real MASTER. Thank you for that function. It works very well.
Have a nice day.
Wolfgang
Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon