Tagged: x
-
AuthorPosts
-
August 3, 2016 at 9:01 am #1115410
Benjamin HParticipantHi there,
We are looking to have the username, date, and tags for each post to display underneath the title of every blog post on the blog home. I used the code in this post: https://community.theme.co/forums/topic/date-stamp-and-author-not-displaying-on-blog-post/
However, this includes the category, not the tags. I don’t want to try and revise it on my own, as I know that can often shut down the site, if not properly done. 🙂
Any help would be appreciated! Our website is: http://www.teens.lvbaptist.org/lvbc-teen-blog/
Thanks!
August 3, 2016 at 12:48 pm #1115766
DarshanaModeratorHi there,
Thanks for writing in! To add tags to the post meta, please refer to the following example code (https://community.theme.co/forums/topic/add-tags-to-meta-in-ethos/#post-215569).
Check the code below the comment.
//TAG LISTHope that helps.
August 3, 2016 at 1:57 pm #1115880
Benjamin HParticipantI’m sorry, but I can’t seem to figure out how to get the tags listed beside the date. Here is my current code. Where am i going wrong. Thank you!
Benjamin
<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Enqueue Parent Stylesheet // 02. Additional Functions // ============================================================================= // Enqueue Parent Stylesheet // ============================================================================= add_filter( 'x_enqueue_parent_stylesheet', '__return_true' ); // Additional Functions // ============================================================================= // Entry Meta // ============================================================================= // Entry Meta // ============================================================================= if ( ! function_exists( 'x_icon_entry_meta' ) ) : function x_icon_entry_meta() { $author = sprintf( '<span><i class="x-icon-pencil"></i> %s</span>', get_the_author() ); $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar"></i> %2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); //TAG LIST $tags = array(); $tags = get_the_tags(); $tags_output = ''; if (is_array(tags)) { foreach ( $tags as $tag ) { $tags_output .= '<a href="' . get_tag_link( $tag->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $tag->name ) ) . '"> ' . $tag->name . '</a>' . $separator; } $tags_list = sprintf( '<span>%1$s %2$s', __( ' Tags:', '__x__' ), trim( $tags_output, $separator ) ); } if ( comments_open() ) { $title = get_the_title(); $link = get_comments_link(); $number = get_comments_number(); if ( $number == 0 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), __( 'Leave a Comment' , '__x__' ) ); } else if ( $number == 1 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $number . ' ' . __( 'Comment' , '__x__' ) ); } else { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $number . ' ' . __( 'Comments' , '__x__' ) ); } } else { $comments = ''; } if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>', $author, $date, $tag, $comments ); } } endif;August 3, 2016 at 4:37 pm #1116118
LelyModeratorHello Benjamin,
Please update the Entry Meta function to this:
// Entry Meta // ============================================================================= if ( ! function_exists( 'x_icon_entry_meta' ) ) : function x_icon_entry_meta() { $author = sprintf( '<span><i class="x-icon-pencil"></i> %s</span>', get_the_author() ); $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar"></i> %2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); if ( get_post_type() == 'x-portfolio' ) { if ( has_term( '', 'portfolio-category', NULL ) ) { $categories = get_the_terms( get_the_ID(), 'portfolio-category' ); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_term_link( $category->slug, 'portfolio-category' ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark"></i> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%s</span>', trim( $categories_output, $separator ) ); } else { $categories_list = ''; } } else { $tags = get_the_tags(); $separator = ', '; $tags_output = ''; foreach ( $tags as $tag ) { $tags_output .= '<a href="' . get_tag_link( $tag->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $tag->name ) ) . '"><i class="x-icon-bookmark"></i> ' . $tag->name . '</a>' . $separator; } $tags_list = sprintf( '<span>%s</span>', trim( $tags_output, $separator ) ); } if ( comments_open() ) { $title = get_the_title(); $link = get_comments_link(); $number = get_comments_number(); if ( $number == 0 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), __( 'Leave a Comment' , '__x__' ) ); } else if ( $number == 1 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $number . ' ' . __( 'Comment' , '__x__' ) ); } else { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $number . ' ' . __( 'Comments' , '__x__' ) ); } } else { $comments = ''; } if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>', $author, $date, $tags_list, $comments ); } } endif;Hope this helps.
August 5, 2016 at 9:07 am #1118882
Benjamin HParticipantThank you! That worked for getting the tags added. Just a couple more questions….
1. There seems to be an issue with the “Leave a Comment” wording getting pushed out of line. Is there a way to remove that text?
2. Can we get the number of comments to show up in the comment circle?
3. Also, can we change the color on the comment circle at the top, both for the circle background, as well as the number of comments?
Site link: http://www.teens.lvbaptist.org/lvbc-teen-blog/
Thanks!
August 5, 2016 at 8:17 pm #1119655
Rue NelModeratorHello There,
Thanks for the updates!
Please update the code and use this instead:
// Entry Meta // ============================================================================= if ( ! function_exists( 'x_icon_entry_meta' ) ) : function x_icon_entry_meta() { $author = sprintf( '<span><i class="x-icon-pencil"></i> %s</span>', get_the_author() ); $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar"></i> %2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); if ( get_post_type() == 'x-portfolio' ) { if ( has_term( '', 'portfolio-category', NULL ) ) { $categories = get_the_terms( get_the_ID(), 'portfolio-category' ); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_term_link( $category->slug, 'portfolio-category' ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark"></i> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%s</span>', trim( $categories_output, $separator ) ); } else { $categories_list = ''; } } else { $tags = get_the_tags(); $separator = ', '; $tags_output = ''; foreach ( $tags as $tag ) { $tags_output .= '<a href="' . get_tag_link( $tag->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $tag->name ) ) . '"><i class="x-icon-bookmark"></i> ' . $tag->name . '</a>' . $separator; } $tags_list = sprintf( '<span>%s</span>', trim( $tags_output, $separator ) ); } if ( comments_open() ) { $title = get_the_title(); $link = get_comments_link(); $number = get_comments_number(); $text = ( 0 === $number ) ? '0' : sprintf( _n( '%s', '%s', $number, '__x__' ), $number ); if ( $number == 0 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $text ); } else if ( $number == 1 ) { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $text ); } else { $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments"></i> %3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $text ); } } else { $comments = ''; } if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>', $author, $date, $tags_list, $comments ); } } endif;And to change the color of the circle at the top, please go to your customizer, Appearance > Customize > Icon.
Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1115410 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
