Please use below code to show posts in texonomy and titles
$s = $request['s'];
$tags = str_replace(' ', '-', strtolower($request['s']));
$q1 = get_posts(array(
'fields' => 'id',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
's' => $s
));
$q2 = get_posts(array(
'fields' => 'ids',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'tag' => array($tags)
));
$unique = array_unique( array_merge( $q1, $q2 ) );
$posts = get_posts(array(
'post_type' => 'post',
'post__in' => $unique,
'posts_per_page' => -1
));
if ($posts ) :
foreach( $posts as $post ) :
//show results
endforeach;
endif;
Related Posts:
- Display related products with custom output
- WP Query with custom Shortcode
- How can I modify this code to make the search box include tags and meta
- Query multiple custom post types in single loop
- How to find objects by terms
- How do I dynamically generate args for wp_query?
- How to get to a specific position in wp_query?
- Use wp_get_recent_posts with search term
- have_posts() execution failure
- Why is variable not working on custom sql query using wpdb?
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- Can’t search posts using WP_QUERY inside AJAX Function
- WordPress pagination not working with search page
- Create WP_Query to search for posts by their categories or their parent/child categories
- WordPress default Search function inconsistent in WooCommerce Product Titles
- unable to use ‘new WP_Query’ in AJAX call
- Exclude posts with specific metadata from search?
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- Form search query – displaying ACF “Post Object” field as results
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- How to display SQL query that ran in WC_Order_Query?
- How to hide posts of a specific custom category in WordPress?
- Search.php gets metadata from first post
- Free search and custom taxonomy query not providing the same result
- search.php to search only the post title
- WordPress Search Ajax + Isotope + InfiniteScroll
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Replace a single variable with add_filter
- Build A Custom SQL Query for WordPress Search
- Using a new WP_Query inside the loop
- meta_query search names when they have middle initials
- wordpress query returning unexpected results
- Query doesn’t display text data with apostrophes
- Include search tags and users in my search results system
- making a search.php query
- How can I display a query in a page?
- Does wp_query and query_posts affect website performance? [duplicate]
- wp_query on search results page showing all results every time
- Show post like this image in my newssite [closed]
- Three different queries on same page
- Best Practice for PHP
- The correct method to pass query vars in AJAX using ajaxurl
- if statement on database query
- WP_Query meta_query results date by date
- Enhanced WordPress Search
- WP_Query search posts by custom post type and custom taxonomy
- Search query – exact post title match
- Help with adding pagination to custom wp_query
- Is it possible to dynamically get queried term AND taxonomy?
- API response to be stored locally
- How to filter posts by post format “standard” from wp-json api?
- Change Navigation Bar based on logged in or not
- How can I add multiple ‘tax_query’ arrays via a loop?
- mysql query from wordpress page using custom table
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- Loading the same WP_Query in two different wordpress .php templates
- How to prevent WP_Query function from returning all posts when empty?
- Save Search System
- How to pre populate a form field with a link of a current user’s author profile?
- Create a Blog Template Page
- Display an image if odd number of posts in grid
- working with term_relationships table
- How to show meta value code HTML after x paragraph
- change the default order of posts only for specific categories
- How can I split my query result in 2 arrays?
- How to get post category list as select in front-end?
- Order a WP_Query by meta value where the value is an array
- How do I check if there is a tag in the title
- Using multiple variables to assign categories to an array
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- the_post(); prints out style text into my HTML?
- search and add in wordpress content
- WordPress Conditional / Multiple Taxonomy Query
- How to call my PHP function with AJAX ? wp_query
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Why pagination is not working with tax_query param?
- WP_Query To Display Product Of Brand On Taxonomy Page
- Search only for posts with specific metadata?
- How to display last whole post on the homepage
- Let user select the number of posts shown per page jquery error
- My search results are only showing 5 posts?
- wp_query beginner
- WooCommerce – Print Processing orders [closed]
- List of child pages fetch next results at link click
- Check if values exists DB
- Trying to exclude posts from a category on the home page
- Different layout on search page depending on category post
- How to get category pages to look like a certain archive page?
- Search box background on a different page template
- Post Title Not showing up
- reorder a WP_Query, using a dropdown
- Search result page – display values from the result’s metaboxes
- Query Concatenation
- How to modify this function to exclude also the post belonging to a specific category?
- Display biography post for today’s birthday person
- Variable ++ in query loop
- a problem in class in class-wp-hook.php
- Count custom posts type and filter by tag
- AJAX WP_Query’s order and orderby parameters not working