Created
December 24, 2019 12:41
-
-
Save Farmatique/26d28f1e9685453da6f37c35c7daa4ed to your computer and use it in GitHub Desktop.
Add search criteria parameter to WP Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$search_str = get_query_var('search') ? get_query_var('search') : ''; // get string from url ?search=search_string (e.g. that what is submitted by ordinary form) | |
$args = array( | |
's' => $search_str //add parameter to query args | |
); | |
$the_query = new WP_Query($args); // standart WP query call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment