Mysql query and order meta value

While the WPDB class, or its global $wpdb instance are your friend when it comes to querying custom tables or WP core data that does not have a higher-level API, it is overkill to use it to query posts. Instead, read up on WP_Query. In your case, you’d use it like so: $args = array( … Read more

Optional Meta Query

All of the real work here is being done by $geoDataStore->getPostIDsOfInRange. That is where the search is done and that is what isn’t returning the results you want. WP_Query just pulls the specified post IDs. There is no reason you should have to abandon that part of the code, though you may want to add … Read more

Query multiple meta values

You code is generating a broken meta_query. You code will produce something like this: array(1) { [“meta_query”]=> array(2) { [0]=> array(2) { [“relation”]=> string(2) “OR” [0]=> array(3) { [“key”]=> string(4) “test” [“value”]=> string(10) “test_value” [“compare”]=> string(4) “LIKE” } } } It should look like this: array(1) { [“meta_query”]=> array(2) { [“relation”]=> string(2) “OR” [0]=> array(3) … Read more

how to make URL link query string

This is how I got it working: ADDED this to functions.php: function include_template_function( $template_path ) { global $wp; if ($wp->request == ‘state’) { $template_path = locate_template( array ( ‘state.php’ ) ); } return $template_path; } $state_name = $_GET[‘st’]; //this is added to use as a global variable ADDED THIS to header.php because WP thinks it’s … Read more

Query posts with numeric meta values within a given range

I ended up finding two solutions within WordPress’ capabilities. Storing available rather than unavailable dates The first solution would be to have the agency select all available dates rather than selecting unavailable dates. Our example listing would then have a custom field listing_available: update_post_meta($post_id, “listing_available”, “/20140101/20140102/20140103/20140104/”); I would then be able to run the following … Read more

meta_query compare=’!=’ with multiple custom fields

This might require writing custom sql with a subquery: $results = $wpdb->get_results(” SELECT * FROM $wpdb->posts WHERE ID NOT IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘my_custom_field’ and meta_value = 2 ) “); then just iterate through the results as described here.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)