Skip to content

Instantly share code, notes, and snippets.

@lots0logs
Last active April 19, 2020 08:16
Show Gist options
  • Select an option

  • Save lots0logs/e2add9834332ee48b608 to your computer and use it in GitHub Desktop.

Select an option

Save lots0logs/e2add9834332ee48b608 to your computer and use it in GitHub Desktop.
WordPress :: Divi Theme :: Include Tags In Post Meta When Displayed On Frontend
<?php
/* DON'T copy the first line (above) if your functions.php already has it.
* ----------------------------------------------------------------------- */
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 ) ){
if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) ) $postinfo_meta .= ' | ';
$postinfo_meta .= get_the_tag_list( '', ', ' );
$postinfo_meta .= ' | ';
$postinfo_meta .= get_the_category_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 );
}
return $postinfo_meta;
}
@StartMeUp

Copy link
Copy Markdown

Works like a charm, many thanks !

@murph73

murph73 commented Apr 12, 2018

Copy link
Copy Markdown

Works perfectly - thanks a lot :)

@Roia2529

Copy link
Copy Markdown

Thanks a lot! This is what I am looking for.

@JeffersonCPT

JeffersonCPT commented May 23, 2018

Copy link
Copy Markdown

This is great thanks so much – would you pretty pleas be able to help me do the following?
Where does one edit the styling of these meta tags to have a rollover colour change for example

@themkvz

themkvz commented Nov 7, 2018

Copy link
Copy Markdown

Thanks !
Its work ! :)

@anonymousguyx

Copy link
Copy Markdown

It isn't working with Divi Blog module.

@Danilfilatov

Copy link
Copy Markdown

Modified this code and added code to add tags in Blog module: https://gist.github.com/Danilfilatov/df5adf5a1a4d39a306c31c4ae481a030

@NathansUncle

NathansUncle commented Jan 17, 2019

Copy link
Copy Markdown

I followed the instructions and no tags showed in my posts. But then coding always works like a charm for other people, but not for me. LOL! Any advice?

@pattyayers

pattyayers commented Feb 8, 2019

Copy link
Copy Markdown

Awesome, this works great, thank you! It works on Single Post screens, which is what I need.

@TomOverthere

Copy link
Copy Markdown

Thank you, lotsOlogs. Elegant Themes Divi tech support referred me to this page in response to my question about how to display Date | Category | Tag as a single line of text. Your code works beautifully, and I can't understand why Elegant Themes hasn't implemented something similar...

Two comments, neither of which is meant as criticism:

  1. The tags don't show up on the blog page list, as mentioned by at least one other user. That's not very important, though. More important for visitors to see and search Category and Tag from the individual post.

  2. I may be mistaken, but I think post meta information typically displays Category first, followed by Tag. I simply switched the two instructions in your (extremely easy-to-follow) code and it's PERFECT.

Again, thanks a LOT.

@TomOverthere

Copy link
Copy Markdown

For those who say this code does not work for them, I note that the change does NOT appear in Divi's Visual Builder, nor does it appear in the 'New' Divi Builder previews. It DOES, however, appear when you select View Page, which takes you to the actual page displayed on the Internet.

So don't be fooled. The code works very well. Category and Tag names are searchable (too good) and they adhere to whatever visual formatting you chose in the Blog Title module's Elements section. A real problem solver.

@Geoplous

Geoplous commented Sep 7, 2019

Copy link
Copy Markdown

Modified this code and added code to add tags in Blog module: https://gist.github.com/Danilfilatov/df5adf5a1a4d39a306c31c4ae481a030

@Danilfilatov
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment