Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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’.

    #1373832

    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

    #1373861

    Hi thanks for that. Doesn’t seem to be working for me though. Example here: https://owe.brother.design/sites/oxpens-phase-1/

    #1374239

    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

    #1374252

    That’s worked, thanks!

    #1374457

    Hi,

    Glad Ismael could help!

    In Enfold 5.3, we have added an option “Page Element Filter” to exclude page content from ALB subqueries for various elements :)

    Best regards,
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.