How to show monthly archive posts?

Create a file date.php in your active theme and use below code, you may need to polish this code as per your requirement: <div id=”content” class=”post-archive<?php echo $content_class; ?>”> <?php if ( have_posts() ) : ?> <header class=”archive-header”> <h3 class=”archive-title”> <?php if ( is_day() ) : ?> <?php printf( __( ‘Daily Archives: %s’ ), ‘<span>’ … Read more

How to get the date of all blog posts

If you want to get the dates of all blog posts then you’ll need to perform your own query and loop that. This is the query: <? $posts = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1 )); ?> Now you’ll need to loop those posts like so: <? if( $posts->have_posts() ) : while( $posts->have_posts() … Read more

ACF Field to set Publish Date – Post Duplication upon Update

Drew, one thing about your code above is that the word dateAllergy should be in quotation marks like. I’m not sure of that is the problem but it’s worth changing. $datefield = get_post_meta($post_id, ‘dateAllergy’ ,true); Also, I just noticed that your $post_id variable will be empty too. You should change that to $post->ID. That would … Read more

How to randomize published date for WordPress custom post type

You can specify the argument post_type for the function get_posts() (see all available arguments here). So this line $posts = get_posts( array( ‘numberposts’ => -1, ‘post_status’ => ‘any’ ) ); will become this line $posts = get_posts( array( ‘numberposts’ => -1, ‘post_status’ => ‘any’, ‘post_type’ => ‘portfolio’ ) );

remove author and date from all posts [closed]

For those who have the same issue, I solved it by doing the following: Within Apparence -> Customize -> Blog Post Options -> uncheck “post Date” uncheck “post Author” These settings, removed the author and date from the post. Then, commenting the following line from single.php /*$cmsms_post_author_box = get_post_meta(get_the_ID(), ‘cmsms_post_author_box’, true);*/ And then, I’ve changed … Read more

wp_date doesn’t work

I was able to make my local WP installation display the date in French: switch_to_locale( ‘fr_CA’ ); echo wp_date( ‘F d’ ); Output: octobre 11 (Note that I didn’t have to localize my date format string (ie, no __() inside the wp_date() call.) However, when I tried Dutch: switch_to_locale( ‘nl_NL’ ); echo wp_date( ‘F d’ … Read more

the_time() cannot be placed correctly

<p> <?php the_time() ?> </p> It helps with separation of concerns and increases readability of code as well as being consistent with WordPress coding standards and the default coding style. The first method you attempted is completely invalid, the_time() only accepts 1 parameter, the date format. The second method has roots in validity, but the_time() … Read more