Home Forums WoodMart support forum Add year to blog posts

Add year to blog posts

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #376616

    Pernilla
    Participant

    When showing blog posts, is it possible to add the year in the date?

    #376661

    Hello,

    Unfortunately, there is no option.

    If you have any questions please feel free to contact us.

    Best Regards

    #376673

    Pernilla
    Participant

    Ok, thanks
    in which file can I find the blog list? (to add my own code)

    • This reply was modified 1 year, 11 months ago by Pernilla.
    #376988

    Hello,

    Please add this code to the functions.php of the child theme:

    if ( ! function_exists( 'woodmart_post_date' ) ) {
    	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 Y' ); ?>
    				</span>
    			</div>
    		<?php
    	}
    }

    You will get the result like this: https://gyazo.com/a0dbde93c3f78290dafccfd05fc8f2fe

    Best Regards

    #377024

    Pernilla
    Participant

    Thank you Elise!!
    I appreciate a lot! Just what I wanted!!

    Thanks 😍

    #377205

    You are welcome! We are here to help.

    Wish you a wonderful day!

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

The topic ‘Add year to blog posts’ is closed to new replies.