Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display post types on facets with duplicate labels. #2541

Merged
merged 2 commits into from
Jan 12, 2022
Merged

Conversation

JakePT
Copy link
Contributor

@JakePT JakePT commented Jan 5, 2022

Description of the Change

When two or more taxonomy facets are added with the same label, such as the core category ("Category") taxonomy and the WooCommerce product_cat (also "Category") taxonomy, they are not differentiated on the front end. This PR adds the labels for associated post types in parentheses to the headings of taxonomy facets whenever there are other facets with the same label. For example, if both the category taxonomies mentioned above are added they will be displayed as "Category (Posts)" and "Category (Products)", but if only one is present then the post type will be omitted.

Alternate Designs

I experimented with displaying the post types as little badges next to the headings, like on search results, but it required a bit too much CSS and I was not confident that the appearance would be consistent across different themes.

Benefits

If a user adds taxonomy facets with ambiguous headings, they will automatically be differentiated.

Possible Drawbacks

In some cases the post type name may be ambiguous to end users and the site owner may not want to expose it to them. Arguably "Posts" falls into this category for sites that normally present these as "News" or "Articles". Long term a more robust user interface where users can enter any arbitrary heading they like for facets may be preferable.

Verification Process

  1. Set up a site with Instant Results. The site should have multiple taxonomies with the same label. Using WooCommerce is the simplest way to do this.
  2. Configure Instant Results with a single Category (category) facet. On the front end this facet should be labelled "Category".
  3. Add a Category (product_cat) facet. On the front end this should be labelled "Category (Products)" and the existing Category (category) facet should be labelled "Category (Posts)".
  4. Remove the Category (product_cat) facet. On the front end the remaining Category (product_cat) facet should be labelled just "Category".

For sites where one of these taxonomies is associated with multiple post types, the post types should all be listed, separated by comments. For example, if the category taxonomy is added to Pages then the label should be "Category (Posts, Pages)" when another category facet is present.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Addresses #2497.

Changelog Entry

Adds post types to facet labels when needed to to differentiate facets with duplicate labels.

@JakePT JakePT self-assigned this Jan 5, 2022
@JakePT JakePT requested a review from felipeelia January 5, 2022 12:14
@JakePT JakePT linked an issue Jan 5, 2022 that may be closed by this pull request
@mckdemps mckdemps added this to the 4.0.0 (beta 2) milestone Jan 11, 2022
@mckdemps mckdemps assigned felipeelia and unassigned JakePT Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instant Results: Duplicated Taxonomy Facets Titles
3 participants