Custom Post Type Archives by Date and Taxonomy

Lets use the classic example of a custom post type called “movies”, with its own taxonomy called “genre”. By registering the custom post type (with a “movie” slug), the permalinks are already set up for <domain>/movie/action/ …to see all movies in the action genre. But, archives by date, like <domain>/2010/09/ …don’t know about the custom … Read more

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

I need to use PHP’s DateTime(). It’s currently displaying GMT time instead of the time that’s set for the timezone setting (EST) in the WordPress Admin. How can this be converted to show the the time base $time = new DateTime(); echo $time->format(“Y-m-d h:i:s”); // 2015-08-12 04:35:34 (gmt) // 2015-08-12 12:35:34 (what i want — … Read more

What’s the difference between get_the_time and get_the_date?

Both function returns date and time. What’s the difference between them? Do you have any example? Thanks. 2 s 2 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’, … Read more

How to get date for each post?

I’m using the following to get the date of each post: while (have_posts()) : the_post(); //some html <li class=”icon-date”><?php the_date(‘Y-m-d’);?></li> <li class=”icon-time”><?php the_date(‘H:i:s’);?></li> However, I am only getting the date for first post why is that? 2 I ran into the same problem several times, following changes worked for me in the past: while (have_posts()) … Read more

Proper formatting of post_date for wp_insert_post?

What is the proper way to define the post date when submitting a post from the front end using wp_insert_post (Trac)? My snippet now is publishing with the mysql time… if (isset ($_POST[‘date’])) { $postdate = $_POST[‘Y-m-d’]; } else { $postdate = $_POST[‘2011-12-21’]; } // ADD THE FORM INPUT TO $new_post ARRAY $new_post = array( … Read more