Does meta_query work within get_posts array?
Not possible with an empty value. See: How can I show posts only if meta_value is not empty
Not possible with an empty value. See: How can I show posts only if meta_value is not empty
I’ve been using the following plugin for Event management, and it has short code to display all events and sort them by date. It also has some developer features to give you a bit more control over things. http://wordpress.org/extend/plugins/events-manager/ Very cool plugin that is actively developed.
I don’t think there’s an easy to sort by three different meta values, and really, I don’t see why you need to in this case. Why not just save the event date in one meta value and sort by that? It makes your query much more efficient (removes two unnecessary joins) and lets you use … Read more
If I understand your question correctly, this should work: function get_event_info($event_id = 0, $info = ” ) { global $wpdb; return $wpdb->get_col( $wpdb->prepare( “SELECT meta_value from $wpdb->postmeta WHERE meta_key = ‘%s’ AND post_id IN (SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = ‘event_id’ AND meta_value= %s )”, $info, $event_id ) ); } Use this like … Read more
$yesterday = array ( ‘year’ => date(‘y’), ‘month’ => date(‘m’), ‘day’ => date(‘d’)-1 ); $rows = $wpdb->query($wpdb->prepare(*emphasized text* “SELECT id, yymmdd FROM plugin_data WHERE yymmdd LIKE ‘%d-%d-%d”, $yesterday[‘year’], $yesterday[‘month’], $yesterday[‘day’] )); foreach ( $rows as $r ) { $id_for_yesterday_rows[]= $r->id; } Now you have all ids or rows that were submitted yesterday in an array.
So, after one minute of more thinking, there is an easy solution, although i did not try it myself: $transient=”_transient_timeout_” . $_your_transient_name; $transient_timeout = get_option ( $transient ); you should be ready to go with this. Another Way throught the database would be: $transient=”_transient_timeout_” . $_your_transient_name; global $wpdb; $query = ‘SELECT option_value FROM ‘ . … Read more
Best I can tell is that those default widgets get options from the database as their classes are constructed, so there’s no way to prevent the DB queries without disabling those widgets entirely. Depending on your needs, you may want that slight performance bump and do not need the widgets, in which case you can … Read more
If you want to and only need to do what @tf suggested, what is just to take care of displaying a 0 if no value is present, you can construct a function to do so like this: function wpse121165_return_carprice() { $ecpt_carprice = get_post_meta($post->ID, ‘ecpt_carprice’, true); if(! empty( $ecpt_carprice ) ){ return $ecpt_carprice; } else { … Read more
It is not advised to make use of custom SQL queries if there are functions in WordPress that already does the job. To accomplish this, you can simply make use of wp_get_object_terms(). The first parameter $object_ids takes a string or an array of object ID’s. In your case, you can make use of an array … Read more
I’ll post this as an answer, even though I don’t know much about caching. If you read about WP Object Cache it says: By default, the object cache is non-persistent. This means that data stored in the cache resides in memory only and only for the duration of the request. Cached data will not be … Read more