Advertisement
Misplon

Polestar add categories to post meta

Oct 9th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. if ( ! function_exists( 'polestar_post_meta' ) ) :
  2. /**
  3.  * Print HTML with meta information for the sticky status, current post-date/time, author, comment count and post categories.
  4.  */
  5. function polestar_post_meta() {
  6.     if ( ( is_home() || is_archive() || is_search() ) && get_theme_mod( 'post_date', true ) ) {
  7.         echo '<span class="entry-date"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date() ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span></a>';
  8.     }
  9.  
  10.     if ( is_single() && get_theme_mod( 'post_date', true ) ) {
  11.         echo '<span class="entry-date"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date() ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span>';
  12.     }
  13.    
  14.     /* translators: used between list items, there is a space after the comma */
  15.     $categories_list = get_the_category_list( esc_html__( ', ', 'polestar' ) );
  16.     if ( $categories_list ) {
  17.         /* translators: 1: list of categories. */
  18.         printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'polestar' ) . '</span>', $categories_list ); // WPCS: XSS OK.
  19.     }  
  20.  
  21.     if ( get_theme_mod( 'post_author', true ) ) {
  22.         echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a></span></span>';
  23.     }
  24.  
  25.     if ( comments_open() && get_theme_mod( 'post_comment_count', true ) ) {
  26.         echo '<span class="comments-link">';
  27.         comments_popup_link( esc_html__( 'Leave a comment', 'polestar' ), esc_html__( 'One Comment', 'polestar' ), esc_html__( '% Comments', 'polestar' ) );
  28.         echo '</span>';
  29.     }
  30. }
  31. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement