Can I combine 2 fields into one facet filter?

  • prakashreddy.imduri
    Participant
    4 years, 3 months ago #30121

    Can I combine 2 fields into one facet filter, we’ve several custom fields in the taxonomy, out of these, we want to combine 2 fields into as one facet filter. Is this at all possible either by custom code changes?
    The backend CMS still carry the fields separately on custom content, but search facet filter to show the values of 2 fields into on filter.
    Please suggest.

    wpsolr
    Keymaster
    4 years, 3 months ago #30122

    Please follow the code example: /forums/topic/building-a-custom-facet-from-an-acf-post-type-relationship/
    The idea is to use a WPSOLR action to insert your custom field value calculated from your taxonomies or custom fields (or anything else).

    • This reply was modified 4 years, 3 months ago by wpsolr.
    prakashreddy.imduri
    Participant
    4 years, 3 months ago #30220

    In our case we need to combine to 2 post taxonomies filters into one filter (Sectors and Products & Services into Sectors). Is it work as in the below link?
    /forums/topic/building-a-custom-facet-from-an-acf-post-type-relationship/

    Can you please suggest us?

    wpsolr
    Keymaster
    4 years, 3 months ago #30221

    It can, yes. Your 2 post taxonomies will be combined into a custom field.

    prakashreddy.imduri
    Participant
    4 years, 3 months ago #30222

    For that should we need to enable ACF extension from active extensions?

    wpsolr
    Keymaster
    4 years, 3 months ago #30223

    ACF is not needed. For example /forums/topic/building-a-custom-facet-from-an-acf-post-type-relationship/#post-8673 is not using ACF.

    prakashreddy.imduri
    Participant
    4 years, 3 months ago #30226

    Thanks for your reply. In which file we can add the custom filter code.
    add_filter(WPSOLR_Events::WPSOLR_FILTER_POST_CUSTOM_FIELDS, ‘post_custom_fields’, 10, 2);

    wpsolr
    Keymaster
    4 years, 3 months ago #30227

    In a custom plugin, or in your child’s theme functions.php.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.