Home › Forums › Pro Support › How to show tags?
- This topic has 5 replies, 3 voices, and was last updated 5 years, 10 months ago by
Tom.
-
AuthorPosts
-
March 16, 2017 at 2:54 am #1772
J
ParticipantHi there, starting to learn WPSP. Is there a way to show the tags of a post below each entry in a list?
I saw the option Include terms. This will show the category of a post at the bottom of each entry. I looked for a similar option like Include tags.
JWMarch 16, 2017 at 9:52 pm #1778Tom
KeymasterCurrently it can only display the terms based on the taxonomy selected.
I can see the usefulness in being to display terms taxonomy terms though (categories, tags etc..).
I just opened it as an issue to fix: https://github.com/tomusborne/wp-show-posts/issues/8
March 20, 2017 at 5:22 am #1786J
ParticipantThanks. Would be great to have it.
January 28, 2018 at 12:30 pm #3450Denise
ParticipantHello WPSP Friends,
This thread was opened several months ago. It’s now January 2018. Is there any update on when we might have the ability to show post tags in the meta data, next to the date and category?
This is an essential requirement for my site and I’d really like to use WP Show Posts Pro, since I’m also using GeneratePress pro.
If not, can you suggest a work-around? Perhaps a hook or filter that I can put in the functions.php?Many thanks,
DeniseJanuary 29, 2018 at 7:50 pm #3467Denise
ParticipantHi Tom,
I was able to get the tags to display in the meta data area of WP Show Posts after the title by using the code pasted below.
This is the format: date | category | tag1, tag2, tag3
The date format I’m using is short month and year. (Jan 2018)
This puts pipe separators between each item. And the separator for multiple tags is a comma.add_action( 'after_setup_theme','tu_move_post_meta' ); function tu_move_post_meta() { remove_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' ); add_action( 'wpsp_after_title','wpsp_add_custom_meta' ); } function wpsp_add_custom_meta() { $cat_title = single_cat_title("",false); $year = get_the_time('Y'); $month = get_the_time('m'); $date = '<a href="https://www.mydatapal.com/' . $year .'/'. $month . '/">' . get_the_time('M Y') . '</a>'; $cats = get_the_category_list( ', '); $tags = get_the_tag_list(' | ',', '); echo '<div class="mdp-meta">' . $date . ' | ' . $cats . $tags . '</div>' ; }
Not sure if that’s the most elegant solution, but it worked =)
Thanks again for the awesome support and plugin!
~ DeniseJanuary 29, 2018 at 10:11 pm #3468Tom
KeymasterLooks great!
Instead of the
$date
format you have set up, you may be able to do this:add_action( 'after_setup_theme','tu_move_post_meta' ); function tu_move_post_meta() { remove_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' ); add_action( 'wpsp_after_title','wpsp_add_custom_meta' ); } function wpsp_add_custom_meta() { $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() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $date = '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'; $cats = get_the_category_list( ', '); $tags = get_the_tag_list(' | ',', '); echo '<div class="mdp-meta">' . $date . ' | ' . $cats . $tags . '</div>' ; }
-
AuthorPosts
- You must be logged in to reply to this topic.