Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1346477

    On a portfolio page, the portfolio grid is present as a kind of index to quickly view of portfolio items. It’s set to show 6 items, however that includes the portfolio item that is displayed on the active page. Can the portfolio grid exclude the content on the current page so that it isn’t duplicated?

    #1346545

    Hey m,

    Thank you for the inquiry.

    You can use this filter in the functions.php file to exclude the current portfolio item from the grid element.

    function avia_portfolio_query( $query, $params ) {
    	if(is_single()) {
    		$id = get_the_ID();
    		if(avia_post_grid::$grid == 0) $query['post__not_in'] = array($id);
    	}
        return $query;	
    }
    add_filter( 'avia_post_grid_query', 'avia_portfolio_query', 10, 2);
    

    Best regards,
    Ismael

    #1346593

    Thank you. I tried this with the child folder functions.php file, but it broke the website.

    #1346602

    can you try this instead:

    function ava_exclude_current_post($query) {
      // you can use here aswell  :   if(is_single()){ 
      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');
    #1346603

    Thank you. Same result.

    #1346637

    but you are using a child-theme or where did you enter that snippet?
    you can see that it is working on my installation : https://webers-testseite.de/portfolio/john-dietz-elektrotechnik/ … and pirol ( i did not change the rest of all portfolios.

    #1346645

    Yes, a child theme is used. I tried this with the child folder functions.php file.

    #1346646

    that is correct. But you see that on my testpage all is ok.
    Did you have on top of your child-theme functions.php that

    <?php
    

    this introduction must remain above!

    #1346666

    Yes it is there. You can see it in the link provided.

    #1346719

    Hi,

    Thank you for the update.

    You have to copy the snippet directly from this forum, not from your email. The error occurs because some of the characters in the snippet have been converted to their html entity code.

    Best regards,
    Ismael

    #1346752

    Perfect, thank you for this tip! The second set of code works brilliantly.
    This can be closed.

    #1346814

    Hi,

    Glad to know it is now working! Copying code from your email and pasting it to the code editors converts parts of the snippet to something else, causing that error that you previously encountered. Just make sure to copy the snippets directly from the forum next time.

    Let us know if there is anything else we can help you with.

    Have a nice day.

    Best regards,
    Ismael

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Can the Portfolio grid auto not show the portfolio item of the current page?’ is closed to new replies.