Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Searching based on multiple CPT

Viewing 8 posts - 11 through 18 (of 18 total)
  • Ross Moderator
    #241990

    Hi Keith

    I’ve had a quick look at this.

    The issue is, a make or a model is only a numeric value in the post meta (the post ID), so any kind of sorting related to this post meta doesn’t really work, logically.

    I’ve had a look through ACF forums for this sort of thing and they don’t provide a simple solution:
    https://support.advancedcustomfields.com/forums/topic/orderby-post-object-title-not-post_id/

    However there is this one:
    https://support.advancedcustomfields.com/forums/topic/ordering-by-custom-field-of-relationship-field-object/

    But again its very complicated.

    Essentially, you need to get all the posts from the relationship field, order them alphabetically, store their IDs in the correct order, and then sort our results using that order – its would be rather complex and probably not very efficient (in terms of amount of processing taken to achieve that affect)

    We do have a filter to allow custom ordre of results in this way – so if you want to go down that road I can share (its not listed in our docs yet because we had planned to change the name)

    Thanks

    Keith White
    #241994

    Ross,

    Thanks for the reply. I will take a look at the ACF post today. Please do share the filter for the custom ordering of results.

    Ross Moderator
    #242002

    Hi Keith

    The filter is sf_apply_filter_sort_post__in

    $post__in = apply_filters('sf_apply_filter_sort_post__in', $this->query_args['post__in'], $this->query_args, $this->sfid);

    Which takes an array of post IDs (the results S&F has found) and must return those posts.

    You’ll then have to disable sorting and sort by post__in in the query (actually, you might be able to leave this set as “default” ordreing in your search form options), you can use the sf_edit_query_args filter to do this.

    If you’re going to follow the link above exactly, the JOIN option might work for you anyway, but there’s two potential approaches for you to try.

    Thanks

    Keith White
    #242592
    This reply has been marked as private.
    Ross Moderator
    #242621
    This reply has been marked as private.
    Keith White
    #242680
    This reply has been marked as private.
    Keith White
    #242734
    This reply has been marked as private.
    Ross Moderator
    #242791
    This reply has been marked as private.
Viewing 8 posts - 11 through 18 (of 18 total)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.