MagicB85
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Recent Posts Widget Extended] Show category after dateThis is how my code looks now:
if( $args['date'] ): if ( $args['date'] ) : $date = get_the_date(); if ( $args['date_relative'] ) : $date = sprintf( __( '%s ago', 'recent-posts-widget-extended' ), human_time_diff( get_the_date( 'U' ), current_time( 'timestamp' ) ) ); endif; elseif ( $args['date_modified'] ) : // if both date functions are provided, we use date to be backwards compatible $date = get_the_modified_date(); if ( $args['date_relative'] ) : $date = sprintf( __( '%s ago', 'recent-posts-widget-extended' ), human_time_diff( get_the_modified_date( 'U' ), current_time( 'timestamp' ) ) ); endif; endif; $id = get_the_ID(); $categories = get_the_category(); if ( ! empty( $categories ) ) { $date .= sprintf(__(' in %s', 'recent-posts-widget-extended' ), $categories[0]->name ); } $html .= '<time class="rpwe-time published" datetime="' . esc_html( get_the_date( 'c' ) ) . '">' . esc_html( $date ) . '</time>'; endif;Forum: Plugins
In reply to: [Recent Posts Widget Extended] Show category after dateI solved it.
In functions.php I added this lines in date section:
$id = get_the_ID(); $categories = get_the_category(); if ( ! empty( $categories ) ) { $date .= sprintf(__(' in %s', 'recent-posts-widget-extended' ), $categories[0]->name ); }
Viewing 2 replies - 1 through 2 (of 2 total)