Skip to content

Conversation

jsnmoon
Copy link
Contributor

@jsnmoon jsnmoon commented Sep 30, 2019

Changes proposed in this Pull Request:

This enables filtering by custom taxonomies using search widget checkboxes.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

Yes, this adds support for custom taxonomy filtering to Jetpack Instant Search.

Testing instructions:

  • Add define( "JETPACK_SEARCH_PROTOTYPE", true ); to your wp-config.php.
  • Ensure that your site has the Jetpack Pro plan and Jetpack Search enabled.
  • Ensure that your site has configured a custom taxonomy. An example code snippet follows how one might register a custom taxonomy for your site.
  • Add a Jetpack Search widget to the Search page sidebar.
  • Add a custom taxonomy filter to the Jetpack Search widget.
  • Enter a query into a search widget. Alternatively, navigate to a search page like /?s=privacy.
  • Ensure that you can select a custom taxonomy filter checkbox.
  • Ensure that other search filters, like dates and post types, still work as expected.

Configuring a custom taxonomy:

This following code snippet, when added to wp-content/mu-plugins/functions.php, will register a custom taxonomy named Speakers.

function register_speakers_taxonomy() {
    register_taxonomy( 'speakers', array( 'post' ), array(
        'label'    => __( 'Speakers' ),
        'template' => __( 'Speakers: %l.' ),
        'helps'    => __( 'Separate speakers with commas.' ),
        'sort'     => true,
        'args'     => array( 'orderby' => 'term_order' ),
        'rewrite'  => array( 'slug' => 'speakers' ),
    ) );
}
 
add_action( 'init', 'register_speakers_taxonomy' );

Proposed changelog entry for your changes:

None.

Jason Moon added 2 commits September 27, 2019 16:25
This refactors how we handle query strings, which affects our API logic.
@jsnmoon jsnmoon added [Status] Needs Review This PR is ready for review. [Feature] Search For all things related to Search Instant Search labels Sep 30, 2019
@jsnmoon jsnmoon requested review from gibrown and a team September 30, 2019 20:53
@jsnmoon jsnmoon self-assigned this Sep 30, 2019
@jsnmoon jsnmoon changed the title Add/instant search custom taxonomy filtering Instant Search: Add custom taxonomy filtering support Sep 30, 2019
@jsnmoon jsnmoon changed the title Instant Search: Add custom taxonomy filtering support Instant Search: Add custom taxonomy filtering Sep 30, 2019
Copy link
Member

@gibrown gibrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some bugginess in the display here for non-English characters, but we have other places we need to fix up filtering display bugs also, so let's get this merged and then fix them all up.

https://cloudup.com/cdZFwcZw33R

@jsnmoon jsnmoon merged commit 38ab1d9 into instant-search-master Oct 2, 2019
@jsnmoon jsnmoon deleted the add/instant-search-custom-taxonomy-filtering branch October 2, 2019 19:41
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Needs Review This PR is ready for review. labels Oct 2, 2019
jsnmoon added a commit that referenced this pull request Oct 23, 2019
* Implement minimal search results and spelling correction (#13365)
* Add filtering display (#13371)
* Fix search result display bugs and make improvements (#13393)
* Add rudimentary support for filtering on post types (#13430)
* Add support for filtering on categories and tags (#13505)
* Add instant search sorting based on the URL (#13377)
* Add support for filtering on dates (#13545)
* Add custom taxonomy filtering (#13605)
* add sort widget (#13614)
* fix many theme incompatibilities (#13602)
* Add infinite scrolling (#13684)
* Add caching to the api requests (#13714)
* Clean up some design bugs/issues (#13721)
* Fix labels for post types when we have them. (#13750)
* Add localization and formatting of all dates (#13748)
* search from any page on the site (#13713)
* Hook up default options (inc. sort) (#13742)
* Add TrainTracks analytics (#13730)
* Create PostTypeIcon component (#13790)
* Upgrade to Preact 10 (#13794)
* Add comments component (#13797)
* Address review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search For all things related to Search [Type] Feature Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants