$search_query = get_search_query(); $args = array( 'relation' => 'OR', array( 'key' => 'title', 'value' => $search_query, 'compare' => 'LIKE' ), array( 'key' => 'author_name', 'value' => $search_query, 'compare' => 'LIKE' ) ); $wp_query = new WP_Query($args); I know that this code is meta_query style, but I'm trying to have OR in WP_Query … [Read more...] about WP Query
Wp meta_query meta_key
How do I get all the posts where the value in wp_postmeta.meta_value is the selected city? I now use the code below, but this doesn't work 100% because I use the LIKE method. So if I select "York" I get "York" and "New York". The meta_value is sometimes translated with qtranslate-x and somethimes not. So … [Read more...] about how to get the qtranslate-x meta_value in wp_postmeta using WP_Query?
array( 'key' => 'wpl_location', 'value' => serialize(array(3 => 'Europe')), 'compare' => 'LIKE' ), I believe the second method would require me to have a (near) identical serialized array as the database, which would not work in the long-term for the system that I am creating, because it will need to match one out of many items in the array. … [Read more...] about WP_Query Posts by Metadata from Option Tree
I have an acf field called totalviews. It stores the total views number for each page i have. The field is number/numeric. Then I am trying to find the page with most views so i sort the number i store in acf field using a wp_query inside functions.php file but i get wrong sort order results. Its messed up not ASC nor DESC ... is my query right? Any help appreciated. … [Read more...] about wp_query sort with meta_value_num is not working
In this project visitors can select to filter their search by selecting multiple locations, each entry on the site has multiple locations linked to them, so when the visitor selects multiple locations some of the entries should have more then one meta key value that matches. … [Read more...] about wp_query order by amount of matching meta keys