Per comments above from mmm
Try this
$posts = get_posts(["s" => "string to search"]);
Also, Covering the get_posts
API is a bit beyond a single StackExchange answer, but if you want to dive deep you’ll find more informations in the codex.
Related Posts:
- Enhanced WordPress Search
- Build A Custom SQL Query for WordPress Search
- Search results always returns “No results” no matter what
- Transaction when using WP functions rather than vanilla SQL?
- How to get the list of WooCommerce product image of a certain category from database?
- Alter query on edit.php
- Modifying widget search box
- How to auto login user again after change user_login
- Rewriting search and pagination base
- How to Join two tables from separate databases within WordPress
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- count number of user comments with a specific comment meta value
- Adjust the results quantity for Search Results page pagination
- How do I get images (with a thumbnail preview) to show in search results?
- my function doesn’t return my post from today
- How do I dynamically generate args for wp_query?
- register_activation_hook isn’t adding table to DB
- Add relevant tag to search results
- How to generate page content from database the right way?
- Use wp_get_recent_posts with search term
- If search results empty then execute certain code
- phpMyAdmin displays error when importing database
- have_posts() execution failure
- Preferred Method of debugging a wordpress SQL calls?
- Change Navigation Bar based on logged in or not
- Can’t search posts using WP_QUERY inside AJAX Function
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Get stock by custom meta field on all Woocommerce variable products
- WordPress pagination not working with search page
- Transferring working local PHP site to wordpress – with database (MySQL)
- Input type search in Menu
- Display fields as values in array from external SQL DB
- WordPress Search Results for Multiple Post Types
- WP Query with custom Shortcode
- Importing Geo data into wordpress database
- Detect session/cookie variable in wordpress to prevent access to documents
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Save Search System
- Seach custom post type posts only by meta fields?
- Autocomplete search box
- Can anyone offer any help with this function?
- Exclude posts with specific metadata from search?
- Use Tags to initiate Search
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- Use $wpdb or other PHP script method to find/replace in WP database
- Form search query – displaying ACF “Post Object” field as results
- PHP -> SQL Query with Summing
- Pull MySQL data from multiple tables and merge into 1 PHP array
- How do I remove duplicate users from two merged WP_User_Query objects?
- mySQL queries are executed twice on wordpress website
- Search page results conflicting logic – Search result caching?
- Search.php gets metadata from first post
- Remove password protection from all posts
- wordpress sql posts query won’t display the latest post in a specific category
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- search and add in wordpress content
- WP_Query: How to get results from both meta_key options?
- How can I modify this code to make the search box include tags and meta
- Free search and custom taxonomy query not providing the same result
- WordPress Search Ajax + Isotope + InfiniteScroll
- how can i include post meta in search result
- My worpress search page is showing no results
- Replace a single variable with add_filter
- WordPress SQL Prepare
- How to search order using database frontend short code WordPress
- Change ajax live search results
- meta_query search names when they have middle initials
- Fetch Data from an external MSSQL Database in a Managed WP hosting
- Limit Search to Product Pages only unless I’m on Blogpage or Blogposts
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Showing search results on a page
- What is the correct way to search 3 custom fields only in WordPress?
- Collect all events in one year
- Search only for posts with specific metadata?
- Search function not working
- My search results are only showing 5 posts?
- Getting error in sql query
- user update profile for custom code
- Where to check in PHPmyAdmin / SQL database for subdomain
- Front end/Database connection in WP
- Plugin Modification Change Functionality For Logged User Only
- SQL Query Search page
- Conditional statement within WP SQL query
- Can not manually create a database ( db, user, pass ) for a plugin
- How to merge 2 WordPress sites?
- Select All not working in a WordPress search filter
- Different layout on search page depending on category post
- Make the text field in search form optional
- How to export database correctly for local to online
- Search box background on a different page template
- Trying to put a search page on site
- Search result page – display values from the result’s metaboxes
- How to strip/remove all blank spaces at the beginning/end of a search string
- Retrieve data from external database and insert back in
- Search custom post type posts only by meta fields?
- SQL query to retrieve the number of WordPress posts with all given categories
- Limit a search box by CPT + taxonomies, in only one page
- Product Search in search.php