For now I’ve just redirected the default search string (www.sitedomain.com/?s=keyword
) to www.sitedomain.com/trade/keyword
, (trade is my custom taxonomy) although I’m pretty sure this isn’t the correct or best way to do it so it’d be great if someone else has a better solution. Here is the code for redirecting the search string:
function redirect_search() {
if ( is_search() && ! empty( $_GET['s'] ) ) {
wp_redirect( home_url( "/trade/" ) . urlencode( get_query_var( 's' ) ) );
exit();
}
} add_action( 'template_redirect', 'redirect_search' );
Related Posts:
- Include custom taxonomy term in search
- Advanced search form with filters for custom taxonomies and custom fields
- How to replicate some of Drupal Views functionality in WordPress?
- Exclude from search all custom posts which are NOT in a taxonomy term
- Exclude a term of a taxonomy with a custom post type in a search
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Custom search for custom post type, custom meta and search fields
- Is there An Input Checkbox Option That Works like `wp_dropdown_categories()` To Use In A WP Search Form?
- How to search from specific post type with tags?
- Include different loop templates in search query
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- CPT Search Form with Taxonomy filter & Or
- Keyword search limited to specific post type filtered by multiple custom taxonomies?
- How to create an advanced filter search?
- search also in taxonomy, tags and custom fields
- WordPress sort search results by custom order
- Pretty URL for custom search for custom post type
- Auto Complete Search
- Search by tag name and category
- Advanced search form with filters for custom taxonomies
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Include custom taxonomy term in search
- how to get this tax_query working?
- Custom Taxonomy Search result page
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Custom Search | check multiple meta_value for search value
- Hide custom post type from search based on custom taxonomy
- Ideas on how to organize a project [closed]
- Multi Parameter search with custom post type category and tag
- How to Implement Search Functionality?
- How to have multiple search result pages in wordpress with taxonomy terms listed
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Live search by custom tag
- Custom search for a custom post type in WordPress
- Extensive search filtering and results->PDF in the front-end
- Advanced search form with filters for custom taxonomies and custom fields
- Archive custom template from search
- Custom Field Search
- Search for portfolio tags & mixing portfoliotags and post tags
- How do I display the taxonomy for a custom post type in an array
- Custom taxonomy rewrite with query var returns %2F in URL
- WP Rewrite Rule Issue while using Custom post type & taxonomy
- How to list custom taxonomies in the back end
- Several CPT’s with same Taxonomy name but with different Terms for each
- Remove slug in URL custom post type
- Custom Permalinks with CPT and Hierarchical Taxonomies
- How to conditionally redirect to the post from a taxonomy page?
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- Sort and filter custom post type posts by custom taxonomy
- How do I display the grand child items of a taxonomy term?
- Add post location with mile radius allowing search
- How to edit this code to get the categories in achieve page?
- Taxonomies relations
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Is it better to use WordPress Custom Post Types or Taxonomies?
- Get general taxonomy name for a Custom Post Type
- Include custom post type content in search
- Display Custom Taxonomy Alphabetically
- Import data from CSV with custom taxomony empty
- WordPress uses url different from defined in rewrite arg of custom post type
- Custom Post Type Loop with Query Var
- Full Custom Post Type List Organised by two Taxonomies
- Is it possible to use have_posts function to list custom post type posts inside a category?
- Get post count for search result based on post type
- WordPress Doesn’t Generate Taxonomy Archive
- URL rewriting for CTP assigned entity
- How to have this permalink structure: post_type/postname/custom_inner_page
- Suggested Post and Taxonomy structure
- How do I require the specification of term in a custom post type and custom taxonomy?
- Custom Post, set object Taxonomy terms in plugin
- Query Custom Post Type Taxonomy term with multiple parameters
- Display post content with respect to its title?
- Hierarchy and access control for Custom Post Types (CPT)
- Custom Post Type Pagination Paginates Only in URL Structure
- Set post terms for multiple posts
- search suggest – filter post type
- Load Custom_post_type categories post with ajax
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Searching Custom Post Types
- Custom taxonomy returns 404
- Get terms that contain posts that in turn belong to other terms?
- WP-API select custom taxonomy when creating a post
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- First custom field value (out of several) displayed twice after query
- Custom post with more than one custom taxonomy
- How to get custom posts sub category link
- Custom while loop for hierarchical display of a taxonomy
- Terms showing up in object cache on unrelated pages
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Get the taxonomy of a post hierarchically
- Adding custom taxonomy in same menu place with two custom post types
- How to make custom taxonomy into drop down select in a custom metabox
- Including taxonomy term before post type breaks top level pages
- Correct procedure for advanced permalinks
- Permalinks: custom post type -> custom taxonomy -> post
- How do i search authors from search form using author’s name
- List Taxonomy Terms based on another Taxonomy
- How to get the intersection of two terms both from different custom taxonomies
- CPT’s with landing page instead of archive – Url Rewrite?
- Template for all categories of a custom post type?