in section 2.2 I can’t overide labels for CPT’s

  • webmasterbslnl
    2 weeks, 6 days ago #33246

    Hi there,

    I have several CPT’s. I am able to add ‘type’ to the filter section in 2.2 (which can be seen in the actual search on the front end of the site) but I am not seeing my CPT’s in the list of labels after clicking on ‘override each item label’. I do see labels for ‘Halfpage’, ‘Leaderboard’ and ‘Rectangle’ but those are not my CPT’s.
    Type is selected in 2.2:
    Weird labels:
    I am on version 23

    2 weeks, 6 days ago #33247

    The procedure is:
    1. Screen “2.2 Data”: select the CPTs, with their taxonomies and custom fields, which you want to index
    2. Screen “2.4 Facets”: configure the CPT taxonomies and custom fields that you want to display in the facets widget

    2 weeks, 6 days ago #33248

    in 2.2 Data I have (and had) selected all CPT’s I wanted indexed selected (
    in 2.4 Facets I selected ‘type’ among others. It does make the CPT’s show up in the facet widget correctly but with their original names. In the list of label overrides I see only the 3 mentioned labels but not my CPT’s. We have multiple WordPress sites, I normally am able to override labels for those, like this: But in this specific site the CPT’s do not show up and thus cannot be overridden.

    2 weeks, 6 days ago #33250

    I understand that you do not see your CPT labels in the facet “type” field labels.

    From wpsolr-pro/wpsolr/core/classes/extensions/premium/includes/theme/
    Line 41, the labels are obtained from standard get_post_types() function:
    $post_types = get_post_types();
    Line 23, unless hook WPSOLR_Events::WPSOLR_FILTER_FACET_ITEMS is used somewhere to return custom values
    $facet_items = apply_filters( WPSOLR_Events::WPSOLR_FILTER_FACET_ITEMS, [], $facet_name_standard, $selected_val );

    2 weeks, 5 days ago #33256

    I found that $facet_items = apply_filters( WPSOLR_Events::WPSOLR_FILTER_FACET_ITEMS, [], $facet_name_standard, $selected_val ); returns the wrong labels. Input values for $facet_name_standard and $selected_val are ‘type’. Traced it to wpsolr-pro/wpsolr/pro/extensions/acf/class-wpsolr-plugin-acf.php:164 where the filter is added for ACF. $field = acf_get_field( $facet_name ); returns a custom field we indeed named ‘type’. It has nothing to do with CPT’s. We just defined an ACF field and named it ‘type’.

    So it seems that if you somewhere create an ACF field and name it ‘type’, you end up not being able to override labels for CPT’s in 2.4 Facets.

    I managed to work around the issue by manually exporting facet config, added the correct translations to the json and imported it all back. The manual additions actually work great in the frontend.

    2 weeks, 4 days ago #33261

    Thanks for the feedback!

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

You must be logged in to reply to this topic.