Get date of last update outside of loop

It is unclear if you are looking for the last updated post or for the last updated date for some particular post. The answer by @PatJ assumes the former. To do the latter: $qry = new WP_Query(array(‘p’=>1)); var_dump($qry->posts[0]->post_modified); Or… $date = $wpdb->get_var(“SELECT post_modified FROM {$wpdb->posts} WHERE ID = 1”); var_dump($date); Of course you need to … Read more

Custom Post Type Archives by Date with Custom Permalink

Here’s the solution: Install Custom Post Type Archives plugin Go to Settings->Post Type Archives Remove the url base option (leave it blank) Change the template pattern to archive-{POST_TYPE}.php Tick your custom post type and click save Rewrite/save your custom permalink structure Now your links press-release/%year% and press-release/%year%/%month% should work.

How to List Events by Year and Month Using Advanced Custom Fields?

This should get you started: <?php $the_query = new WP_Query( array( ‘post_type’ => ‘kalender_item’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘kalender_item_datum’, ‘orderby’ => ‘meta_value’ ) ); # This will hold what group we’re in $current_header=””; # The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); # get the datum for this post $temp_date = get_post_meta( get_the_ID(), ‘kalender_item_datum’, … Read more

How to schedule multiple posts while adding new

Here’s a sketch of another idea, where we create scheduling shortcuts to make it easier for the users: We can use the post_submitbox_misc_actions to add extra fields to the submit box: /** * Scheduling-Shortcuts fields. * * @see http://wordpress.stackexchange.com/a/168748/26350 */ add_action( ‘post_submitbox_misc_actions’, function() { if( ! current_user_can( ‘publish_posts’ ) ) return; ?> <div style=”padding: 2px … Read more

Custom Post Type Archives by Date and Taxonomy

Yes, there isn’t currently built-in support for CPT archives, but that doesn’t mean you can’t extend WP to provide it. I just did this myself the other day… This won’t create the date-based archives you’re looking for, but it will give you virtual archive behavior for custom post types. Adding the date should just be … Read more

How to convert DateTime() to display time based on WordPress timezone setting?

I’m not sure why EliasNS’ answer is marked correct, as far as I’m aware (and from the documentation), the second parameter of DateTime::__construct(), if provided, should be a DateTimeZone instance. The problem then becomes, how we do we create a DateTimeZone instance. This is easy if the user has selected a city as their timezone, … Read more

Default timezone hardcoded as UTC?

Somehow I missed the current_time function, which gives a good description of the situation and how to properly deal with the need to get the current blog-local time. http://codex.wordpress.org/Function_Reference/current_time Though the purist in me still hates how WP makes the time zone setting in php.ini obsolete without giving you a choice. *grumble grumble*

What’s the difference between get_the_time and get_the_date?

They are, very similar but with some nuances: function get_the_date( $d = ” ) { global $post; $the_date=””; if ( ” == $d ) $the_date .= mysql2date(get_option(‘date_format’), $post->post_date); else $the_date .= mysql2date($d, $post->post_date); return apply_filters(‘get_the_date’, $the_date, $d); } function get_the_time( $d = ”, $post = null ) { $post = get_post($post); if ( ” == … Read more