Jetpack Search: Taxonomy filters not displaying
Impacted plugin
Search
Steps to Reproduce
- Go to https://tspa-iss-1219.mystagingwebsite.com/explore/resource-library/
- Enter a keyword on the Search input (eg: "safety" returns valid results)
- Check out the filters on the right panel
A clear and concise description of what you expected to happen.
A taxonomy filter for Categories should be displayed
What actually happened
A list of filters for Date and Post Type is displayed, but not the filter for Categories.
Other information
- This happens for custom taxonomies as well. For all taxonomies actually.
- On the Production site, it happens only for custom taxonomies but not for Categories
- Could potentially be related to this old issue reported here.
- On the cloned test site, there was a taxonomy rename that required SQL updates. However, the issue is also replicable in Production where none of these changes have taken place yet.
Below are screenshots of the configuration:
Operating System
macOS
OS Version
11.6.5
Browser
Chrome/Chromium
Browser Version(s)
100.0.4896
Hi @ecairol thanks for reporting this. I think the issue is because we don't support all taxonomies, and another bug report could be found here.
Would you please try to remove all customized taxonomies and leave only category and tag and see if it works? so that we can confirm the issue. Thanks.
Also hi @gibrown, are you able to provide some suggestions on how we could resolve this? Thanks. I'm thinking potentially we should at least hide the unsupported taxonomies from the widget taxonomy dropdown.
Cheers
cc @Automattic/jetpack-search
@kangzj @gibrown thanks, let me try that out today and I'll confirm with you here.
@kangzj ya the full list of taxonomies is available so limiting what the user can select would be a good fix here.
@gibrown @kangzj that would be a great UX.
What's the feature that makes a taxonomy supported or not for the filter panel? Is it all custom taxonomies?
@ecairol Search explicitly synced taxonomies could be found here:
https://github.com/Automattic/jetpack/blob/64ce40fcd3fc2def48ba7b8f49b5712280cd2ddf/projects/packages/sync/src/modules/class-search.php#L683
And also taxonomies registered on the site: https://github.com/Automattic/jetpack/blob/64ce40fcd3fc2def48ba7b8f49b5712280cd2ddf/projects/packages/sync/src/class-functions.php#L41
Black listed: https://github.com/Automattic/jetpack/blob/64ce40fcd3fc2def48ba7b8f49b5712280cd2ddf/projects/packages/sync/src/class-defaults.php#L427
@ecairol Also what plugin registers the customized taxonomies you are using? I might have a play and see. 😄
@kangzj wow that's quite a list!
The customized taxonomies are registered via code, eg:
register_taxonomy(
'tspa-resources-topic',
self::POST_TYPE,
array(
'label' => __( 'Topic', 'tspa' ),
'description' => __( 'The resource topic to be grouped under.', 'tspa' ),
'public' => true,
'hierarchical' => true,
'show_admin_column' => true,
)
);
I noticed that at the end of $taxonomies_to_sync list there are a few exceptions made for End The Backlog (which is another site maintained at Special Projects), so I wonder if we could make another exception and add these three to that whitelist?
tspa-resources-topictspa-resources-typetspa-curriculum-type
@ecairol spun up a diff to add the three taxonomies: D82983-code
@ecairol Also, feel free to use jetpack-search-tag0 - jetpack-search-tag9 which are already supported for custom taxonomies. 😄
I'll spun another PR to limit the list shown in the drop down, so that users would know, we don't support all taxonomies.
Also, feel free to use jetpack-search-tag0 - jetpack-search-tag9
Thank you very much @kangzj - I think I'll wait for the three taxonomies to be added, just to keep it semantically clear. But I'll keep that in mind for the future.
D82983-code
I'm getting a "You Shall Not Pass: Restricted Differential Revision" message when I visit D82983-code – ~Do you know if there's a way for me to keep track of when this is released? Or an estimated date?~ I guess I can check the Changelog in a week or so and I'd see the change listed there?
I'll spun another PR to limit the list shown in the drop down, so that users would know
That sounds good, yes! Thanks
Hi @ecairol the requested taxonomies are now supported thru D82983-code, would you mind doing a full sync and see how it goes?
An important thing to note: We are about to only show the officially supported taxonomies from the next release of Jetpack and Search plugins. You'll need to hook a filter to add customized taxonomies for the dropdown. Examples please see: https://github.com/Automattic/jetpack/pull/24823.
If you've got more questions/issues, please just let us know. Thanks.
@kangzj thank you for the heads up.
What do you mean by "doing a full sync" ?
Context:
There's something missing on my side but I'm not sure what. Currently using Jetpack Version 11.2-a.3
I've implemented the jetpack_search_supported_taxonomies on our test site, however, I still cannot see the custom taxonomies on the dropdown. I've also added a die() to see if the execution stops inside the filter, but it didn't.
add_filter(
'jetpack_search_supported_taxonomies',
function( $taxonomies ) {
$taxonomies[] = 'tspa-resources-topic';
$taxonomies[] = 'tspa-resources-type';
$taxonomies[] = 'tspa-curriculum-type';
return $taxonomies;
}
);
The Taxonomy dropdown is now only showing a limited number of options, so I suspect I've got your latest changes, but not the custom taxonomies:
Thanks in advance for any hint you can provide
the requested taxonomies are now supported thru D82983-code, would you mind doing a full sync and see how it goes?
@kangzj can you please clarify what you mean by doing a full sync?
@ecairol you can schedule a full sync from the Jetpack debugger:
https://jptools.wordpress.com/debug/?url=https://tspa-iss-1219.mystagingwebsite.com
I've just scheduled one for you.
Hi @ecairol sorry I was afk for a couple of days. And sorry again, the filter nam was changed to "jetpack_search_allowed_taxonomies_for_widget_filters" in the end. Could you please try it out and see? Thanks
Thank you @bluefuton this is new for me, I've made note for future reference.
No worries @kangzj, thanks for the clarification.
-- Update: worked like a charm! Thanks!
Did this functionality for adding custom taxonomies stop working?
I have:
add_filter(
'jetpack_search_allowed_taxonomies_for_widget_filters',
function( $taxonomies ) {
$taxonomies[] = 'tnc_tax_51091';
$taxonomies[] = 'tnc_tax_53440';
return $taxonomies;
}
);
and I did a jetpack debug on the site which above said refreshes the index but these taxonomies have never shown up.
Also, I think I am asking for the correct thing. The issue is that the custom post types do not show up at all in the search. When I had looked into this before I saw this filter as well for the post types which I also have registered. But I can not even find a reference to this filter now:
add_filter( 'jetpack_search_post_types', function( $post_types ) {
$post_types[] = 'tnc_col_50901_item';
$post_types[] = 'tnc_col_55294_item';
return $post_types;
} );
Seems to be related: panfyZ-3QN-p2