Forums Forums Search & Filter Pro Searching based on multiple CPT

Viewing 10 posts - 1 through 10 (of 17 total)
  • Trevor
    #240997

    What Custom Post Types do you envisage?

    I might think of 3:

    Cars (for sale maybe?)
    Makes
    Models

    If you use the free Advanced Custom Fields plugin, you can add Custom Fields to the Cars CPT that are Relational Post Objects (linked to the other 2 CPTs). Thus giving you one CPT to search (cars) with fields for the Makes and Models.

    With those also being CPTs, you can have CPT archive and post pages for them also.

    Anonymous
    #241000
    This reply has been marked as private.
    Trevor
    #241018
    This reply has been marked as private.
    Anonymous
    #241129
    This reply has been marked as private.
    Trevor
    #241287
    This reply has been marked as private.
    Trevor
    #241297
    This reply has been marked as private.
    Anonymous
    #241656
    This reply has been marked as private.
    Trevor
    #241736

    I think the issue is the results page is pulling data from Problem Vehicles so there’s no way to get it to order by Manufacturer.

    Ah, of course. It is ordering by the value in the list, and not the label. That, if you have the PHP skills, can be fixed. You would need to return the sort order settings in the Posts tab back to default, and instead see if you can use this filter:

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

    To somehow set that sort order, but I am not sure how. If you want, I can ask our developer, Ross?

    Anonymous
    #241798
    This reply has been marked as private.
    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

Viewing 10 posts - 1 through 10 (of 17 total)