Hi I have this code to offset the portfolio grid so that it doesn’t list the current portfolio entry:
function ava_exclude_portfolio($query) {
if (is_singular('portfolio')) {
$exclude = avia_get_the_ID();
$query->set( 'post__not_in', array($exclude) );
}
}
add_action('pre_get_posts', 'ava_exclude_portfolio');
How do I tweak this code so it does the same in blog posts grid? Does it need to be tweaked again if displaying custom post type in the blog post element? In this case, the CPT is ‘sites’.
Hey domchocolate,
Thank you for the inquiry.
We adjusted the code a bit to include the blog posts grid.
function ava_exclude_portfolio($query) {
if (is_singular('portfolio') || is_singular('post')) {
$exclude = avia_get_the_ID();
$query->set( 'post__not_in', array($exclude) );
}
}
add_action('pre_get_posts', 'ava_exclude_portfolio');
Best regards,
Ismael
Hi thanks for that. Doesn’t seem to be working for me though. Example here: https://owe.brother.design/sites/oxpens-phase-1/
Hi,
Sorry for the late response. Please try to replace the code with the following filter instead.
/*
Removing duplicate blog post (Blog post element must not have offset activated)
*/
add_filter('avia_post_slide_query', 'avia_post_slide_query_mod');
function avia_post_slide_query_mod( $query ) {
global $post;
if ( is_single() ) {
$query['post__not_in'] = array($post->ID);
}
return $query;
}
We were not able to check the page above because it is password-protected. Please post the password in the private field or provide an admin account.
Best regards,
Ismael
That’s worked, thanks!