If I navigate to Posts -> All Posts
in a Wordpress install, there's a Search Box in the upper right hand corner. Entering terms in this box and clicking the Search Posts button will perform a search.
Does Wordpress provide a hook, function, or other API that would allow me to programmatically perform the same (or a similar) search? i.e. I pass in a string as terms and get back a PHP array of results without needing to write any SQL myself.
If not, does anyone here know where in the Wordpress core code the above search happens? (so I cam mimic the behavior as best as possible)
Thank you!
$posts = get_posts(["s" => "string to search"]);
. you will find more informations in the codex : codex.wordpress.org/Function_Reference/get_posts