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
- Archive post by meta value + 24hours
- edit search.php to include subdomain posts
- Search Query: how to construct a search string from two select elements?
- Genesis framework comments broken?
- $wpdb->insert() does not Insert record in a table
- Can anyone offer any help with this function?
- Databases – Submitting data from inputs to database [closed]
- Search WordPress using static html page
- Exclude posts with specific metadata from search?
- Is it best to avoid using $wpdb for security issues?
- Use Tags to initiate Search
- Search form does not work in my website
- dynamic page using php from sql database
- 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
- How to Update post_modified of all wordpress post
- Correct PHP to output a single result of a Function with SQL Query
- How can I add a new row in a separate database when someone registers via WordPress?
- Form search query – displaying ACF “Post Object” field as results
- Woocommerce Backend Search by Title and SKU
- PHP -> SQL Query with Summing
- Lost in trying to create user database system
- Pull MySQL data from multiple tables and merge into 1 PHP array
- List post by title length
- Filter results from a serialized string to use on statistics
- wordpress site – using custom database and PHP
- How do I remove duplicate users from two merged WP_User_Query objects?
- How do I query a single data value from the wp_metadata table?
- Use variable in SQL statement
- Search only working on front page (index) , not working on other pages
- Live search from database table
- Why my query does not run with prepare
- wpdb getting avatars and author url
- WordPress Search
- mySQL queries are executed twice on wordpress website
- WordPress pagination not working in search result page
- Search page results conflicting logic – Search result caching?
- making php value numeric
- Using color schemes with Color Picker
- WordPress SQL JOIN query
- Search.php gets metadata from first post
- Fetching review value using wpdb class
- Remove password protection from all posts
- quotes problem in very simple sql
- 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
- Validate search against a list of codes in wordpress
- Free search and custom taxonomy query not providing the same result
- search.php to search only the post title
- get_terms with specific id order
- Display WordPress search results based on the selected Sub-Category
- WordPress Search Ajax + Isotope + InfiniteScroll
- how can i include post meta in search result
- Highlighting Text in Search Results
- Database SQL query error
- My worpress search page is showing no results
- Replace a single variable with add_filter
- get different meta-data of a complicated query at the same time
- WordPress SQL Prepare
- How to run complex query using PHP
- Include custom fields in search
- Storing huge number of users in wordpress
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- Using a new WP_Query inside the loop
- add role on WordPress in PHP on a second database
- How to search order using database frontend short code WordPress
- Change ajax live search results
- Trying to create a shortcode to display categories with a specific product tag
- 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
- Creating multiple tables with Plugin
- Adding ELSE argument to AJAX Live Search for “No results found”
- How can i find wrong word in search box and replace with correct word
- Custom User registration system
- How to use Multi SQL Database in WordPress?
- Showing search results on a page
- Help me understand how Search function works using dynamic_sidebar()
- Woocommerce – get daily sales meta
- What is the correct way to search 3 custom fields only in WordPress?
- Running a PHP SQL script on a wordpress page
- Collect all events in one year
- WordPress search query, how to modify the sql
- How do I get data from my database into my Custom Export Field
- Searching a custom WP table and displaying results in an HTML table
- Search only for posts with specific metadata?
- Search function not working
- Inserting other fields to existing registration form in a WordPress theme
- My search results are only showing 5 posts?
- Include search tags and users in my search results system
- Getting error in sql query
- user update profile for custom code
- Where to check in PHPmyAdmin / SQL database for subdomain