Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1238252

    I have a portfolio grid at the bottom of each portfolio item post, showing all of the currently published portfolio posts, except for the current post being viewed. Every time I make a change to my site (publish new posts, unpublish other posts, change the order, change the number of posts), I have to update the portfolio grid at the bottom of each page, which takes way too long.

    Is there a way to make the portfolio grid persistent, so I just have to update it once, and it will appear everywhere? Preferably where it will know not to show the post for the page it is on, and also not show on the home page.

    #1239353

    Hey jh100,

    Thank you for the inquiry.

    How did you exclude the current portfolio item in the grid? If you’re using the Portfolio Grid element, you should be able to use this filter to exclude the current post in the query.

    function ava_exclude_current_post($query) {
      if (is_singular('post')) {
        $exclude = avia_get_the_ID();
        $query->set( 'post__not_in', array($exclude) );
      }
    }
    add_action('pre_get_posts', 'ava_exclude_current_post');
    

    This one should also work.

    
    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

    #1239599

    I’ve been excluding it manually by assigning a different category to each portfolio post and then choosing which ones show on each page. Not ideal.

    I will try your code suggestions, but please tell me: where do I put the code? Which file and where in the file?

    #1239789

    Hi jh100,

    Please try to add the code to the bottom of your functions.php file. If you are not running a child theme then I would advise you to install that first, as the changes will be lost on updates otherwise: https://kriesi.at/documentation/enfold/install-enfold-theme/#why-child-theme

    Best regards,
    Rikard

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