Home Forums WoodMart support forum How do show date with year for blog post?

How do show date with year for blog post?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #563347

    arif
    Participant

    Hi,
    As per stated in the title above, are there any ways so that it also show Year instead of just Day & Month for blog posts?
    Please refer the attached image.

    screenshot of blog posts

    Thanks in advance for your assistance šŸ™‚

    • This topic was modified 6 months ago by arif.
    • This topic was modified 6 months ago by arif. Reason: just a thanks in advance
    #563473

    Hung Pham
    Keymaster

    Hi arif,

    Thanks for reaching to us.

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    function woodmart_post_date( $args ) {
    	$has_title = get_the_title() != '';
    	$attr      = '';
    	if ( ! $has_title && ! is_single() ) {
    		$url  = get_the_permalink();
    		$attr = 'window.location=\'' . $url . '\';';
    	}
    	$classes  = '';
    	$classes .= ' ' . $args['style'];
    	$classes .= woodmart_get_old_classes( ' woodmart-post-date' );
    	?>
    		<div class="post-date wd-post-date<?php echo esc_attr( $classes ); ?>" onclick="<?php echo esc_attr( $attr ); ?>">
    			<span class="post-date-day">
    				<?php echo get_the_time( 'd' ); ?>
    			</span>
    			<span class="post-date-month">
    				<?php echo get_the_time( 'M' ); ?>
    			</span>
    			<span class="post-date-year">
    				<?php echo get_the_time( 'Y' ); ?>
    			</span>
    		</div>
    	<?php
    }

    Kind Regards

    #565079

    arif
    Participant

    Hi,
    I’ve pasted your code into my child theme’s functions.php, however it doesn’t seems to work like I wanted to.
    blog post's date still the same
    Are you sure this code is working?

    • This reply was modified 5 months, 3 weeks ago by arif.
    #565348

    Hung Pham
    Keymaster

    Hi arif,

    First of all, Iā€™m really sorry have taken long time to reply you due to the weekend.

    To assist you in the best possible manner, I kindly ask that you please provide me temporary wp-admin info (wp-admin URL, username, password) and screenshots that illustrate the problem to the Private Content area, this will allow me to thoroughly investigate and address your concerns more efficiently.

    Regards,

Viewing 4 posts - 1 through 4 (of 4 total)