You can check if you are on a tag page with a conditional, and then modify the main query:
add_action( 'pre_get_posts', 'search_the_title', 1 );
function search_the_title($query){
// Check if it's the main query
if ( $query->is_main_query() && !is_admin()) {
// If it's a tag page, search posts by tag
if ( is_tag() ) {
$query->set('s' , get_query_var('tag' , ''));
// Unset the current tag to search all posts
unset( $query->query['tag'] );
return;
}
// If it's a taxonomy page, search by taxonomy value
if ( is_tax('topic') ){
$query->set('s' , get_query_var('topic' , ''));
// Unset the current taxonomy to search all posts
unset( $query->query['tax_query'] );
return;
}
}
}
Related Posts:
- display posts with same taxonomy term
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Loop through custom taxanomy in post and display custom fields from posts
- Only display latest custom taxonomy post
- How to get the term description in a taxonomy term archive query?
- Amend taxonomy to search in wordpress admin
- Add terms to a taxonomy archive from within the same taxonomy
- Get post meta value outside of the loop
- List all posts associated under custom taxonomy
- Custom taxonomy shows full articles
- Exclude 2 in 3 terms of A Taxonomy from all Archives
- Loop custom post type by taxonomy (Category)
- How do I create a term for every value of a post meta?
- Querying posts globally based on custom taxonomy with its own taxonomymeta table
- Using wp_query is it possible to orderby taxonomy?
- custom post type taxonomy “tag” archive : no post found
- Display category posts grouped by taxonomy
- Get taxonomy names by post id
- Return only the custom sub-term for custom post type, do not echo term-parent
- Get total number of comments from posts in a specific custom taxonomy
- Display one post from each term in a custom taxonomy [closed]
- Custom hierarchal taxonomy loses interface hierarchy when selecting parent & children
- Formating the_terms() function output
- Post tags saving as both tag name & tag ID on post update when tags are displayed as checkboxes
- Is it possible to sort the post based on a custom field?
- tax_query not working on main query
- Combine multiple custom user taxonomy in single url
- Add custom taxonomy to default category taxonomy?
- Display sub-taxonomies based on SELECTED parent-taxonomy
- Checking if a Page has an Associated Term?
- What are terms and taxonomy, how they related to post and how these three are stored in database?
- How to handle “the_terms” inside loop
- Taxonomy , subtaxonomy,child taxonomy of a product woocommerce
- Get terms ordered by post date
- How can I get WP to build a feed based on multiple taxonomy terms
- Change permalink of post if it belongs to custom taxonomy
- Get pages only with a specific taxonomy
- Share taxonomy between user and posts?
- How to filter terms from a custom taxonomy by a usermeta value on all screens and templates
- How do I Use Multiple Loops with WP_Query?
- How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
- How to obtain the link/URL to the feed of a custom taxonomy?
- get_term_children doesn’t return an array of children terms
- How do I display a list of posts under all hierarchical children of the current taxonomy?
- Use get_the_terms to list subcategories of custom taxonomy
- Get taxonomy parent using child slug (from merged taxonomies)
- Display Taxonomy Terms in an option tag with value being the slug
- orderby meta_value breaks taxonomy term archives
- Modify “View” in admin panel for custom taxonomy
- Hide product categories and taxonomy terms in menu if empty
- Custom taxonomy forms for user profile
- get the taxonomies terms associated with users
- Add Taxonomy Subcategory To Permalink
- where is the 4th taxonomy terms? taxonomy terms is disaapearing in the loop
- Replace taxonomy permalinks
- Custom Taxonomy Term Archive Page Template that Filters 2 or more Taxonomies
- Custom Taxonomy with tax_query
- Display all posts that use a custom taxonomy
- Override Taxonomy Template
- Get posts in certain Taxonomy terms for the current page url
- How can I reduce amount of ifs and else ifs in this specific block of code?
- Exclude taxonomy term from all loops, but having it on widget
- Edit custom taxonomy description programatically
- Get taxonomy name for the current post
- View the complete list of a taxonomy in the navigation menu
- Get name of taxonomies of current page
- Add custom taxonomy as a css class
- Taxonomy page shows category in title
- Query custom taxonomy for category including children
- Order taxonomy terms wordpress
- Unsetting post_tag taxonomy breaks term description for other taxonomies
- Taxonomies on Pages with Custom Formatting
- How to combine taxonomies into URL?
- Why do my quick edits for custom taxonomies not show on the post frontend?
- Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives
- Tracking the name of a custom taxonomy
- Show recent posts from a custom taxonomy in wordpress
- Fill New Taxonomies
- Group posts in a category based on tags in custom taxonomy
- how do you pull data from two taxonomies?
- problem : Custom taxonomy template not showing
- How to loop custom posts that have an exact match in taxonomy terms?
- Filter “get_terms” query
- How To Create Dynamic Permalink To Custom Taxonomy List of Current Posts?
- ACF – Get unique values of array
- Remove Custom metabox from particular page template is used
- generate random slug when adding taxonomy
- Only seems to be displaying one child when there are supposed to be multiple
- Sort Taxonomy List by Custom Values
- Query pages by child term
- How to display custom taxonomy
- Taxonomy term breadcrumb; how?
- Custom Taxonomy + JQuery Tabs
- Using wp_query is it possible to orderby taxonomy?
- Group custom taxonomies based on tags contained in their posts
- Make custom post type display with custom taxonomy in url
- How home my code doesn’t display any feature image? Looping through post from a taxonomy and not getting feature images back
- Save selected terms in order of custom taxonomy in post
- Add text in custom taxonomy
- Taxonomy entries are spawning copies of existing entries with the new title as the existing ID, since upgrade