WP_Query() show posts that end later than today

First, your date format has to be in descending order from largest to smallest units, i.e.: year, month, day, hour, minute, second, etc., otherwise MySQL can’t query or order on the field. In this example I use year – month – day: $today = date( ‘Y-m-d’ ); $args = array( ‘post_type’ => ‘vehicle’, ‘meta_query’ => … Read more

Is it possible to Schedule Attachments in WordPress?

My idea is that you can setup a post date for the attachments. This can be done using attachment_fields_to_edit to show the UI (is possible use the touch_time internal function). After that, you can filter all the attachments query to show only the attachments with a past or current date. So add_action(‘load-post.php’, ‘setup_attachment_fields’); function setup_attachment_fields() … Read more

How to order posts of a custom post type by date DESC in dashboard Admin?

Alright, You can just hook into the filter pre_get_posts and check is_admin. Put this in your theme or plugin: function wpse_81939_post_types_admin_order( $wp_query ) { if (is_admin()) { // Get the post type from the query $post_type = $wp_query->query[‘post_type’]; if ( $post_type == ‘Videos’) { $wp_query->set(‘orderby’, ‘date’); $wp_query->set(‘order’, ‘DESC’); } } } add_filter(‘pre_get_posts’, ‘wpse_81939_post_types_admin_order’); I also … Read more

How to integrate get_post_time with date_i18n function?

Use the fourth parameter for get_post_time(): $time = get_post_time( ‘F j, Y’, // format TRUE, // GMT get_the_ID(), // Post ID TRUE // translate, use date_i18n() ); get_post_time() calls mysql2date() internally, and it passes the $translate argument through. In mysql2date() we find this: if ( $translate ) return date_i18n( $format, $i ); So, all you … Read more

The purpose of the post_date_gmt?

Some countries use a Daylight Saving Time (DST): Typically clocks are adjusted forward one hour near the start of spring and are adjusted backward in autumn. Sometimes there is no 2 am. Sometimes you get 2 am two times. To avoid cron jobs running twice or not at all WP needs the GMT (or more … Read more