Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1490771

    I have created a portfolio grid that displays portfolio entries by a specific category and sorted those items by title. However, these portfolio items have custom fields (ACF) and I would like to order by the value of one of those fields. How do I do that?

    Thank you for any guidance!
    KC

    #1490790

    Hey milkrow,

    Thank you for the inquiry.

    Try to use this filter in the functions.php file to adjust the sorting of the portfolio grid items:

    function avf_avia_post_grid_query_mod( $query, $params ) {
        $query['meta_key'] = 'portfolio_order'; // <-- replace this with the actual acf name
        $query['orderby']  = 'meta_value_num';
        $query['order']    = 'ASC';
    
        return $query;
    }
    add_filter( 'avia_post_grid_query', 'avf_avia_post_grid_query_mod', 10, 2 );
    

    Make sure to adjust the meta_key value.

    Best regards,
    Ismael

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