Resolved

Customization for the date

Puro Theme started by rawn Sep 8, 2016 6 replies
rawn Sep 8, 2016 · 6:48 pm #4803

Hello, how do I change the format for the date from D/m/y to m/d/y?

Andrew Misplon Puro Sep 8, 2016 · 6:50 pm #4804

Hi rawn

Thanks for posting. It isn’t possible from within theme settings, it’ll take some custom development. Please, can you confirm which theme you’re using.

In the mean time, please, go to Plugins > Add New and install Code Snippets.

rawn Sep 8, 2016 · 6:54 pm #4805

Puro Premium

Andrew Misplon Puro Sep 8, 2016 · 6:58 pm #4806

Super. Thanks for your support. Once Code Snippets is activated, go to Snippets > Add New and create a new snippet, you can name it as you’d like. Insert the following in the snippet body:

if ( ! function_exists( 'puro_posted_on' ) ) :
/**
 * Prints HTML with meta information for the current post-date/time, author, comment count and categories.
 */
function puro_posted_on() {

	if ( is_sticky() && is_home() && ! is_paged() ) {
		echo '<span class="featured-post">' . __( 'Sticky', 'puro' ) . '</span>';
	}

	if ( is_home() && siteorigin_setting('blog_post_date') || is_archive() && siteorigin_setting('blog_post_date') || is_search() && siteorigin_setting('blog_post_date') ) {
		echo '<span class="entry-date"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date( 'F j Y' ) ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span></a>';
	}

	if ( is_single() && siteorigin_setting('blog_post_date') ) {
		echo '<span class="entry-date"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date( 'F j Y' ) ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span>';
	}

	if ( siteorigin_setting('blog_post_author') ) {
		echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a></span></span>';
	}

	if ( has_category() && siteorigin_setting('blog_post_cats') ) {
		echo '<span class="cat-links">' . get_the_category_list( __( ', ', 'puro' ) ) . '</span>';
	}

	if ( has_tag() && siteorigin_setting('blog_post_tags') ) {
		echo '<span class="tags-links">' . get_the_tag_list( '', __( ', ', 'puro' ) ) . '</span>';
	}

	if ( comments_open() && siteorigin_setting('blog_post_comment_count') ) { 
		echo '<span class="comments-link">';
  		comments_popup_link( __( 'Leave a comment', 'puro' ), __( '1 Comment', 'puro' ), __( '% Comments', 'puro' ) );
  		echo '</span>';
	}

}
endif;

Finally, NB: click the radio button to only run this snippet on the side front-end. Then, save changes and activate.

rawn Sep 8, 2016 · 7:10 pm #4808

You are the best! This one little thing kept me from using the theme for so long, any chance it can be added to the customizer in a future release?

Andrew Misplon Puro Sep 8, 2016 · 7:12 pm #4809

Super 🙂 Really glad I could help out.

Sure, it’s been requested a few times so I can see there is a desire/demand to have control over the date output. I’ll log this as an enhancement request and investigate how to best implement it in an update soon.

7 posts