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

    Hello,

    I hoping for some guidance on using the “portfolio grid” function as a “related projects” element. Works beautifully except it includes the item that the page is about. For example, on the page link below, The Natai is the project but is also referenced as related. Any thoughts on how to remove portfolio items from showing up without removing the category. I’ve set up custom fields on the register-portfolio.php page in hopes there is something that could be done though that. Thanks so much for any assistance you can provide.

    http://paulraffstudio.wpengine.com/portfolio-item/the-natai/ (hosted on WPengine)

    #197125

    Hi shelteredinsound!

    Open /config-templatebuilder/avia-shortcodes/portfolio.php and look for line 659:

    $query = array(	'paged'=> $page, 'posts_per_page' => $params['items'], 'post_type' => $params['post_type']);
    

    Replace it by this:

    $query = array(	'paged'=> $page, 'posts_per_page' => $params['items'], 'post_type' => $params['post_type'], 'post__not_in' => array(get_the_ID()));
    

    Cheers!
    Josue

    #199252

    Can you double check on that line of code? I can’t get the code to correctly remove the post. Thanks very much.

    #199279

    Hi,

    I performed a test locally before posting it, can you create an administrator account and post it here as a private reply?

    Regards,
    Josue

    #199325
    This reply has been marked as private.
    #199329

    The access is not working :/

    Best regards,
    Josue

    #199338
    This reply has been marked as private.
    #199339
    This reply has been marked as private.
    #199400

    Hi!

    You can do what Josue instructed. Edit config-templatebuilder > avia-shortcodes > portfolio.php, find this code on line 658:

    $query = array( 'paged'=> $page, 'posts_per_page' => $params['items'], 'post_type' => $params['post_type']);

    Add the post__not_in parameter plus the posts id that you want to remove on the portfolio grid. As example, remove the “Cascade House” and the “The Natai” entry using this:

    $query = array( 'paged'=> $page, 'posts_per_page' => $params['items'], 'post_type' => $params['post_type'], 'post__not_in' => array( 17,62 ));

    If you can’t find it, you can add this on functions.php:

    function custom_post_grid_query( $query, $params ) {
    	$query['post__not_in'] = array( 17,62 );
    	return $query;
    }
    add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);

    Cheers!
    Ismael

    #268313

    Hello
    I am trying to do the same thing, ie, just remove the portfolio item on which the single page is displaying. I tried to modify the portfolio.php file using the code at the top of this post and it didn’t remove the item on the single page – could you please provide the code to go into the functions.php file instead, just like above here but without a reference to removing specific items (if I knew some php I could probably do it but want to make sure it’s correct). Thank you in advance.

    #268324

    Hi @webwahine,

    Can you post a link to your website please?

    Regards,
    Josue

    #268326
    This reply has been marked as private.
Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Removing specific portfolio items from portfolio grid’ is closed to new replies.