So I am building a WordPress theme for myself to meet my needs, so what I am looking for now is make a search using a get method in php.
If my url is something like this :
http://www.MyWordPressWebsite.com/search.php?string=Bananas+and+apples
In my search.php I would like to do something like this:
string = $_GET["string"];
$fruits_args = array(
'post_type' => 'fruits',
'posts_per_page' => -1,
'cat' => 'fruits'
);
$fruits = new WP_Query($fruits_args);
So how do I making the loop related to the string that I get from the the get method ?
comparing the search string the the post type, category and post title would be enough.
use query_posts() instead and WordPress will handle the search with those parameters. You can add as many parameters as you want.
Example:
For more info visit https://codex.wordpress.org/Function_Reference/query_posts
I hope this help