-
AuthorPosts
-
November 24, 2022 at 6:10 pm #1373806
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’.
November 25, 2022 at 8:46 am #1373832Hey 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,
IsmaelNovember 25, 2022 at 12:27 pm #1373861Hi thanks for that. Doesn’t seem to be working for me though. Example here: https://owe.brother.design/sites/oxpens-phase-1/
November 29, 2022 at 8:46 am #1374239Hi,
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,
IsmaelNovember 29, 2022 at 12:25 pm #1374252That’s worked, thanks!
November 30, 2022 at 2:10 pm #1374457 -
AuthorPosts
- You must be logged in to reply to this topic.
