You have to pass the search query too. To get the search query, you can use the get_search_query()
function, and pass it to the query’s s
parameter:
$search_string = get_search_query();
$args = array(
's' => $search_string,
'posts_per_page' => 12,
'order' => 'DESC',
);
Related Posts:
- Custom search page and search by title, content and tag
- Hi, I wanted to make custom search with multiple fields
- Custom Same Page Search
- WP Search Form Query: Add Author’s posts into search query
- Search a meta field for a value in all posts
- WordPress Paginate $wpdb->get_results
- Custom Search Query
- Creating search form for custom database table
- Search through custom post type and custom fields takes 5 minutes
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- Customise search form in the Widget
- Comment filtering (search)
- Combine multiple words in custom meta search query
- Retrieve and display data from custom db table in admin area?
- How to find if a post with custom_field == X exists?
- Modifying loop on a custom page, strange behaviour
- Search a post using the date it was posted
- Setting custom search engine indexing for a “dynamic WordPress page” with htaccess
- How I display post of the post type group by year of post?
- Custom URL going to 404
- Search result page redirect ex.com/?s=searchterms to ex.com/searchterms
- Load more posts with multiple queries
- Steps for custom data retrieval
- Custom search to display results within same page
- Search widget will search everything in the site, how to limit to only search gallery name
- $wpdb->replace: WHERE?
- wp_query get post custom taxonomy in search.php
- Order posts with a custom field but also without
- How to hook up search results page to a back-end page?
- Admin search post meta
- Save title as custom field on custom post type
- Add content in between of foreach
- Add a searchbox to the body of a page
- Custom Search on Custom Page while preserving the main search function
- Search URL parameters query [duplicate]
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- Applying WP-cli Search & Replace to Static SQL Dump File
- How to create custom search page
- Query for specific custom field
- Display posts by combining multiple meta key
- Custom select query two tables by a meta key
- Fatal error Call to a member function insert() on a non-object [closed]
- custom user meta query
- How to Add Additional Search Button?
- Recent activity query WordPress
- How to query term_id of a Custom Taxonomy by name
- How to Clear Empty Search values?
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- query variables for custom taxonomies
- WordPress search on a custom table
- Adding overlay search to wordpress using add action/filter
- display text generated via custom get query string
- Allow WP users to sort search result on a videos site
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- Custom query pagination with php parameter as arg problem
- Add to search posts query array with post IDS which will appear first
- How to automatically pull an information from a form field onto an other page?
- Query Posts to display all posts with category “custom field value”
- Custom dropdown search form that allows users to select option B based from Option 1
- Query 1 custom post type, each day, alphabetically
- Custom search results
- WordPress custom search – pagination
- Creating a search with tag variable also added for more detailed results
- What shortcode should I use for
- Multiple Taxonomies Using Custom SQL Query
- Two searchforms with different categories/posts per page
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Custom search by several options send on form not works
- Search results load individual post in slide out div
- Custom MySQL query to list post
- Custom Query Arguments
- Custom Query for Taxonomy
- Custom Search Results Page
- WordPress Search on Multiple wp sites
- Create a custom search for Estate Agency WordPress site
- Include plugin´s table in custom query
- How can I make a search term redirect to a page
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Show total sales for each products on search results page Woocommerce
- User Query Multiple Orderby Clause
- Custom Search on media files PDF images pages posts
- Why do I get the timeout warning?
- Add custom html to last sub-menu item
- Manipulating post meta in the customizer
- Php custom query function assistance
- How can I manage my multiple wordpress websites from main website?
- Replace “WordPress” word in title of Dashboard
- How do you modify the WordPress directory structure?
- Change WooCommerce product price based on category and GEO IP country
- Editing the default wordpress search
- Unable to sanitize in customizer and escape in theme without removing ability for user to use “< br >” to insert a line break
- Is it advisable to use `add_rewrite_rule()` to serve a custom page?
- Customizing admin look and feel for just one particular type of user
- 2.9 to 3.0: Pros and cons of upgrading?
- Woocommerce – Remove cart button depending product (post) status
- Login CSS style doesn’t load instantly
- Customizer API and pages
- Editing a theme’s templates
- How to delete orphan userdata from array in wp-options
- Query comments with non-empty ‘author_url’ value on Admin Comments Screen