Home Forums Pro Themes Profitmag Pro Date format on post and header

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #65382
    Zoltán Börcsök
    Participant

    Dear support,

    I’d like to ask how can be the date format modified? It doesn’t matter if I change the wordpress default settings to YYYY-MM-DD, on the site it always shows MM-DD-YYYY format with the Online News Pro template.

    Thank you!

    #65463
    wensolutions
    Keymaster

    Hello @bzoli,

    The Date Format in Online News Pro theme is set in MM-DD-YYYY Format by default. If you want to customize the Date Format as per the Dashboard settings, you will need to make customization via the child theme.

    Child Theme Reference: https://codex.wordpress.org/Child_Themes

    You can also automate the process with child theme generator plugin.

    After creating and activating the child theme, paste the following code in your child theme’s functions.php file :

    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function online_news_pro_posted_on() {
    	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
    	}
    
    	$time_string = sprintf( $time_string,
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date( get_option( 'date_format' ) ) ),
    		esc_attr( get_the_modified_date( 'c' ) ),
    		esc_html( get_the_modified_date() )
    	);
    	$disable_date = online_news_pro_get_option('disable_date');
    	if('false'== !$disable_date){ 
    	$posted_on = sprintf(
    		'%s',
    		'<a class="post-meta-date" href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
    	);
    	} else{
    		$posted_on ='';
    	}
    	$disable_author = online_news_pro_get_option('disable_author');
    	if('false'== !$disable_author){
    		$byline = sprintf(
    			esc_html_x( ' %s', 'post author', 'online-news-pro' ),
    			'<a class="bypostauthor" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a>'
    		);
    	} else{
    		$byline ='';
    	}
    	 
    
    	
    
    	echo '<span class="post-meta-author">' . $byline . '</span><span class="posted-on">' . $posted_on .' </span>'; // WPCS: XSS OK.
    
    }

    This will change the date format in posts as per the Format set in Dashboard Settings.

    Hope this Helps,

    Best Regards !!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.