in section 2.2 I can’t overide labels for CPT’s
2 weeks, 6 days ago #33246
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: https://snipboard.io/6rgAY1.jpg
Weird labels: https://snipboard.io/F9bUh6.jpg
I am on version 23
Harmen2 weeks, 6 days ago #33248
in 2.2 Data I have (and had) selected all CPT’s I wanted indexed selected (https://snipboard.io/7y1kVt.jpg)
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: https://snipboard.io/xIfh0t.jpg) But in this specific site the CPT’s do not show up and thus cannot be overridden.
2 weeks, 6 days ago #33250
- This reply was modified 2 weeks, 6 days ago by webmasterbslnl.
I understand that you do not see your CPT labels in the facet “type” field labels.
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.
You must be logged in to reply to this topic.