-
-
Save Danilfilatov/df5adf5a1a4d39a306c31c4ae481a030 to your computer and use it in GitHub Desktop.
/* (Go to Appearance > Editor) */ | |
/* Code in this file and in the Blog-2.php go to Divi/includes/builder/module/Blog.php - they'll be overwritten if you update Divi. */ | |
/* Search for class="post-meta" and you'll find two matches - one for the visual builder module version, the second for the output on the live website. */ | |
/* Paste this code in the place of the first match (delete the old code in the file first): */ | |
printf( '<p class="post-meta">%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s</p>', | |
( | |
'on' === $args['show_author'] | |
? et_get_safe_localization( sprintf( __( 'by %s', 'et_builder' ), '<span class="author vcard">' . et_pb_get_the_author_posts_link() . '</span>' ) ) | |
: '' | |
), | |
( | |
( 'on' === $args['show_author'] && 'on' === $args['show_date'] ) | |
? ' | ' | |
: '' | |
), | |
( | |
'on' === $args['show_date'] | |
? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '<span class="published">' . esc_html( get_the_date( $args['meta_date'] ) ) . '</span>' ) ) | |
: '' | |
), | |
( | |
(( 'on' === $args['show_author'] || 'on' === $args['show_date'] ) && 'on' === $args['show_categories'] ) | |
? ' | ' | |
: '' | |
), | |
( | |
'on' === $args['show_categories'] | |
? get_the_category_list(', ') | |
: '' | |
), | |
( | |
(( 'on' === $args['show_author'] || 'on' === $args['show_date'] || 'on' === $args['show_categories'] ) && 'on' === $args['show_comments']) | |
? ' | ' | |
: '' | |
), | |
( | |
'on' === $args['show_comments'] | |
? sprintf( esc_html( _nx( '%s Comment', '%s Comments', get_comments_number(), 'number of comments', 'et_builder' ) ), number_format_i18n( get_comments_number() ) ) | |
: '' | |
), | |
// adding tags: | |
( | |
( ( 'on' === $args['show_author'] || 'on' === $args['show_date'] || 'on' === $args['show_categories'] || 'on' === $args['show_comments'] ) && ( get_the_tag_list() && ! is_wp_error(get_the_tag_list()) ) ) | |
? ' | ' | |
: '' | |
), | |
( | |
( get_the_tag_list() && ! is_wp_error( get_the_tag_list() ) ) | |
? '<span class="post-tags">' . get_the_tag_list( '', ', ' ) . '</span>' | |
: '' | |
) | |
); |
/* Now paste this code in the place of the secondd match. Again, overwriting the original code: */ | |
printf( '<p class="post-meta">%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s %9$s</p>', | |
( | |
'on' === $show_author | |
? et_get_safe_localization( sprintf( __( 'by %s', 'et_builder' ), '<span class="author vcard">' . et_pb_get_the_author_posts_link() . '</span>' ) ) | |
: '' | |
), | |
( | |
( 'on' === $show_author && 'on' === $show_date ) | |
? ' | ' | |
: '' | |
), | |
( | |
'on' === $show_date | |
? et_get_safe_localization( sprintf( __( '%s', 'et_builder' ), '<span class="published">' . esc_html( get_the_date( $meta_date ) ) . '</span>' ) ) | |
: '' | |
), | |
( | |
(( 'on' === $show_author || 'on' === $show_date ) && 'on' === $show_categories) | |
? ' | ' | |
: '' | |
), | |
( | |
'on' === $show_categories | |
? get_the_category_list(', ') | |
: '' | |
), | |
( | |
(( 'on' === $show_author || 'on' === $show_date || 'on' === $show_categories ) && 'on' === $show_comments) | |
? ' | ' | |
: '' | |
), | |
( | |
'on' === $show_comments | |
? sprintf( esc_html( _nx( '%s Comment', '%s Comments', get_comments_number(), 'number of comments', 'et_builder' ) ), number_format_i18n( get_comments_number() ) ) | |
: '' | |
), | |
// adding tags: | |
( | |
( ('on' === $show_author || 'on' === $show_date || 'on' === $show_categories || 'on' === $show_comments) && (get_the_tag_list() && ! is_wp_error(get_the_tag_list())) ) | |
? ' | ' | |
: '' | |
), | |
( | |
( get_the_tag_list() && ! is_wp_error( get_the_tag_list() ) ) | |
? '<span class="post-tags">' . get_the_tag_list( '', ', ' ) . '</span>' | |
: '' | |
) | |
); |
/* Add this code anywhere in child theme's functions.php. If you don't have a child theme add it to Divi's functions.php - but then it will be reset if you update Divi: */ | |
/* adding tags to posts */ | |
function et_pb_postinfo_meta( $postinfo, $date_format, $comment_zero, $comment_one, $comment_more ){ | |
$postinfo_meta = ''; | |
if ( in_array( 'author', $postinfo ) ) | |
$postinfo_meta .= ' ' . esc_html__( 'by', 'et_builder' ) . ' <span class="author vcard">' . et_pb_get_the_author_posts_link() . '</span>'; | |
if ( in_array( 'date', $postinfo ) ) { | |
if ( in_array( 'author', $postinfo ) ) $postinfo_meta .= ' | '; | |
$postinfo_meta .= '<span class="published">' . esc_html( get_the_time( wp_unslash( $date_format ) ) ) . '</span>'; | |
} | |
if ( in_array( 'categories', $postinfo ) ) { | |
$categories_list = get_the_category_list(', '); | |
// do not output anything if no categories retrieved | |
if ( '' !== $categories_list ) { | |
if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) ) $postinfo_meta .= ' | '; | |
$postinfo_meta .= $categories_list; | |
} | |
} | |
if ( in_array( 'comments', $postinfo ) ){ | |
if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) || in_array( 'categories', $postinfo ) ) $postinfo_meta .= ' | '; | |
$postinfo_meta .= et_pb_get_comments_popup_link( $comment_zero, $comment_one, $comment_more ); | |
} | |
// adding tags: | |
$tag_list = get_the_tag_list( '', ', ' ); | |
if ( $tag_list && ! is_wp_error( $tag_list ) ) { | |
if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) || in_array( 'categories', $postinfo ) || in_array( 'comments', $postinfo ) ) $postinfo_meta .= ' | '; | |
$postinfo_meta .= '<span class="post-tags">' . $tag_list . '</span>'; | |
} | |
return $postinfo_meta; | |
} |
I'm using the latest Divi revision. It works for me.
Does not display Tags in Blog Module list of posts. But it DOES display Tags in individual Posts.
Better for you to post your question at THIS GitHub thread instead:
https://gist.github.com/lots0logs/e2add9834332ee48b608
See my post of July 29 for a few more details.
Good luck.
Thanks for your answer,
Yes, it works fine for individual Posts, but I was asking to display tags in Blog Module, so I followed the above blog-1 and blog -2 instructions but code is different.
So I made a simple insertion of tags in blogs module with explanation here:
https://gist.github.com/Geoplous/2bc48b319f57ebfc58e1752d2ccdb9be
No. I cannot make it work in the Blog Module.
Hi, I made it work so maybe you want to use the code.
Check here: https://gist.github.com/Geoplous/2bc48b319f57ebfc58e1752d2ccdb9be
Hi, does the above code works after the last DIVI updates? I have the version "3.27.4" and I can not see the code in Blog.php that Blog-1 and Blog-2 dictates to replace it with the tags code.
I made an override in divi-child/module/Blog.php that works but as said I can not find the code that need to be replaced.