How to Query Updated Post in WordPress

You can use this query from perishablepress.com to get post revisions. <?php $today = current_time(‘mysql’, 1); $number = 5; // number of posts if($recentposts = $wpdb->get_results(“SELECT ID, post_title FROM $wpdb->posts WHERE post_status=”publish” AND post_modified_gmt < ‘$today’ ORDER BY post_modified_gmt DESC LIMIT $number”)): ?> <h2><?php _e(‘Recently Updated’); ?></h2> <ul> <?php foreach($recentposts as $post) { if($post->post_title == … Read more

$wp_query when new WP_Query

You are slightly confusing $wp_query global variable with WP_Query class/objects. $wp_query is an object instance of WP_Query, but not every WP_Query object has anything to do with $wp_query global. Function version of conditionals, such as is_search(), always act on main global query. You shouldn’t use them inside filters, since global state might be one thing … Read more

$args Orderby The number

You could use the get_terms_orderby filter: add_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); $categories=get_categories($cat_args); remove_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); with function wpse156153_get_terms_orderby($orderby, $args, $taxonomies ) { return ‘FIELD(t.term_id, ‘ . $args[‘include’] . ‘)’; }

Query Event Posts by Date

You need type casting for custom fields event-start-date and event-end-date. Then it will compare with time() & date() value. You need to add ‘type’ => ‘DATE’, in your meta query args. So your meta query will be like this: switch ($print_type) { case ‘current’: $meta_quer_args = array( ‘relation’ => ‘AND’, array( ‘key’ => ‘event-start-date’, ‘value’ … Read more