Try this code
<?php
$args = array(
's' => $_REQUEST[ 'search' ],
'cat' => 'category_id',
'paged' => $paged
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
//inside the loop
the_title();
the_content();
endwhile;
// Reset Post Data
wp_reset_postdata();
?>
Hope this help
Related Posts:
- Replace/Mute/Stop Search Query
- database search feature
- How do I find users by password?
- get_results using wpdb
- Count & Display Database Queries
- Dealing with Many Meta Values, 30+
- Should I hint table index for search query on wp_post
- Export wordpress table to excel
- Custom Search | Wrong output & question
- How best to inject ads between posts in the loop?
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Change all http to https in mysql databse?
- WooCommerce – Query for ordered products
- PHP variable in WordPress database query
- Block search SQL from happening
- Custom search page and search by title, content and tag
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Query WordPress database by registered date and role
- How to prevent WordPress from retrieving data for the last 10 posts in the database?
- Query from a different database than the default
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- Select Multiple meta_value from WP DB; Single Query
- How can I create a Bible search engine via WordPress? [closed]
- CRUD operations using WordPress database API
- Hook directly into query execution
- Advanced SELECT query with condtional statements
- Select two sums with single get_var statement
- input data and output table [closed]
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- wp-cli search is returning ‘search’ is not a registered subcommand of ‘db’
- cache specific data?
- How Can I Put Meta_Compare in the Database-Query?
- How to paginate information obtained from a query to a custom table?
- Historic WordPress database connection
- Check if an option exists and get its value in one hit
- Query multiple tables at once?
- $wpdb->query can’t insert data
- Custom WordPress Table wpdb
- Best practice to limit results in get_row()?
- How to display content from external db with relevant urls
- Connecting to a different database
- SQL query to set posts in bulk based on the post content
- Query Column of Specific ID from Database Table
- Add search bar to Custom Database Table in WordPress Dashboard
- SELECT SQL_CALC_FOUND_ROWS with wordpress search
- Understanding WordPress Search
- How to display data from db in select list [closed]
- How can I query the db to access current post information?
- Search Character Set Problem
- Compare User meta_value with Product meta_value
- How to insert a value to decimal type field using wpdb->prepare?
- Join Query on WP_USERMETA Table
- Insert NULL value using prepare()
- Job and Employee Performance Tracking with Product Safety
- WordPress Database Query works in phpMyAdmin but not in the code
- Finding a page holding a specific string/URL that is used in the content
- wpdb query to insert images in to post/page gallery
- Set SQL_BIG_SELECTS and MAX_JOIN_SIZE on a WP_Query
- Performance bug – slow DB query
- How to optimise this database query?
- How can we speed up wp_get_nav_menu_items()?
- Extracted CSV as Array for Custom Query Loop
- Should I Use only wpdb Class to Write Custom Queries?
- Generating an HTML table from an array based on dynamic key values
- Filtering data and saving query results
- How to have WP Search widget index dynamically generated content?
- Pulling values from a sepcific row in table
- Searchable database of members using multiple criteria / filters
- Using class id from array for query
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- SQL query to rewrite all media URLs to end with .webp
- Order of search results based off of a backend custom field and also in alpha order
- Relaunch 4.2 utf8mb4 database upgrade
- Where can I find the database changes between WordPress versions?
- When is it appropriate to create a new table in the WordPress database?
- $wpdb variable throw this error Call to a member function get_results() on a non-object in
- I have a problem with my WordPress DB after I tried to install multi-site
- Database sync between local and production
- Database error Deadlock found when trying to get lock; try restarting
- Connect Second Database to WordPress
- update_user_meta() does not work
- Check if column exists for one table in DB
- Allow logged in users to store and display some data
- How to merge two WordPress databases with the same structure?
- How to prevent/delay MySQL connections when an object cache is used?
- “Error establishing a database connection” – Intermittent error on GoDaddy
- Importing Direct to DB – GUID Question
- WordPress site to be able to connect with data on local machine of user
- Debugging – logging database queries
- wp_option table error while importing
- What is wrong here? Issue with post_id and meta_value
- Deleting empty meta key values
- WP 5.5, child themes, customizer and a weird cache issue
- Best way to store 1 billion+ posts?
- What’s the easiest way to connect external database and display data on wordpress?
- Preventing concurrent update of data
- Creating Tables in WordPress Database
- Calling update_user_meta inside of another function doesn’t work
- $wpdb->prepare returns empty array
- Prevent creation of unused database tables?