You should try applying the s
(search) as parameter for your custom query.
See this example here:
$query = new WP_Query( 's=keyword' );
and you can then apply normal loop to iterate through your results. This also performs string match same as like operator %keyword%
you mentioned in comment for @Ravs’ answer.
Refer documentation here.
Related Posts:
- Get all image from single page using this query
- what are the numbers between curly brackets in search query
- Search custom post type by meta data
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- Change searched term
- Search query -> Show all pages except certain template
- Temporarily storing main search result
- Query based on title, with ‘compare’ => ‘IN’
- is_search called incorreclty
- Attempt to improve WP search, can someone check my SQL query?
- Searching With Apostrophe
- How to reset usual $query on search page to push custom $wpdb query there?
- Ideas how to search & replace post_content when string contains a newline?
- How to insert Collate into WordPress search query?
- Slow Search Queries – How to exclude pages, media, excerpt, authors, private posts?
- How to interfere to default search to make it search in custom fields?
- How to manage a particular “order by” for get_search_query()?
- List WordPress Post and Related Attachments outside of a post page
- WordPress search in modified post title
- Filter orders by modify date
- How to add url parameter to every search query in SearchWp?
- Add rewrite rule for archive search
- Restrict WordPress search to a single ACF field
- Modify behaviour of “s” parameter in wp_query
- Sort by postmeta on when searching
- Pagination adds search query (again)
- Speed up search query that searches in post meta?
- How to get all images in Media Gallery with pagination?
- Attachment page tag queries & posts not found
- How to make MySQL search queries with quotes
- $query->set( ‘post_type’, ‘post’ ); not working
- search.php is not generating the right results
- Run search query again without pagination gives no results?
- SQL: Search query to get attachments only of those parents which are published
- is_search called incorrectly
- How to display SQL query that ran in query?
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- How to get comments by post ID?
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- Reversing the order of posts AFTER the query is performed
- simple sql query on wp_postmeta very slow
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- get attachments for all posts of particular post type
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- wpdb get posts by taxonomy SQL
- How to List Events by Year and Month Using Advanced Custom Fields?
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- wordpress query – orderby child post date
- Get wp_get_attachment_url outside of loop
- How do I search events between two set dates inside WP?
- How many WordPress SQL Queries per page?
- Filter the query ONLY for the search results page
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- Custom query_var causes displaying posts archive on front page
- Slow wp_enqueue_media()
- Multipart/formatted MySQL query problem
- What is the most efficient way of implementing a favorite post system?
- How do I create a meta box for dates?
- Remove [gallery] shortcode altogether
- Search and replace text across all posts
- Compare two numeric custom fields
- wp_dropdown_categories with multiple select
- Advanced Custom Fields – Query Efficiency
- Why does get_the_time(‘F j’) return November 30 for all posts?
- Disable slow media queries?
- Query by one meta_key and sort by another (possibly NULL value)
- How to tune search argument in WP_Query to show only exactly the same results?
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- Very slow query
- query multiple taxonomy and show post count
- How to find objects by terms
- Query & Sort Comments by custom comment meta
- Fulltext search in posts sorted by relevancy
- How to create a WP_Query to search the Title or Tag?
- How to get my loop to pull posts into three columns
- How to display lastest post date in the homepage?
- Custom $wpdb Query for Custom Post Type by Category
- Get a user’s most recent post title
- How to limit search to first letter of title?
- Categories and products in random order
- Custom Permalinks Break Search Pagination
- Custom Search | Wrong output & question
- add_query_arg() XSS Vulnerability
- Count user posts by user ID, Post type and Post status
- Can’t pass table to $wpdb->prepare
- Query set using tax_query with relation ‘OR’ modifies category object?
- Custom Query to search through categories
- $query->query_var[‘post_type’] not set for pages
- WordPress Search Filter Only for Page with Child of Child of Child of Child of Child
- is_archive() doesn’t work on public query var archive pages?