SHARE
TWEET

Add comment link, categories and tags to TwentySeventeen

ulfben Nov 27th, 2017 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //twentyseventeen/template-parts/post/content.php
  2. <?php
  3. /**
  4.  * Template part for displaying posts
  5.  *
  6.  * @link https://codex.wordpress.org/Template_Hierarchy
  7.  *
  8.  * @package WordPress
  9.  * @subpackage Twenty_Seventeen
  10.  * @since 1.0
  11.  * @version 1.2
  12.  */
  13.  if(!function_exists('categories_and_tags')) {
  14.         function categories_and_tags(){
  15.             $result = '';
  16.             if('post' !== get_post_type()){
  17.                 return $result;
  18.             }
  19.             $separate_meta = __( ', ', 'twentyseventeen' );    
  20.             $categories_list = get_the_category_list( $separate_meta );
  21.             $tags_list = get_the_tag_list( '', $separate_meta );           
  22.             if(($categories_list && twentyseventeen_categorized_blog() ) || $tags_list){
  23.                 $result .= '<span class="cat-tags-links">';    
  24.                 if($categories_list && twentyseventeen_categorized_blog()){
  25.                     $result .= '<br />&nbsp;<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
  26.                 }
  27.                 if($tags_list && !is_wp_error($tags_list)) {
  28.                     $result .= '<br />&nbsp;<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';
  29.                 }
  30.                 $result .= '&nbsp;</span>';
  31.             }
  32.             return $result;
  33.         }
  34.     }
  35. ?>
  36.  
  37. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  38.     <?php
  39.     if ( is_sticky() && is_home() ) :
  40.         echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
  41.     endif;
  42.     ?>
  43.     <header class="entry-header">
  44.         <?php      
  45.         if('post' === get_post_type()){
  46.             echo '<div class="entry-meta">';
  47.                 if ( is_single() ) {
  48.                     twentyseventeen_posted_on();
  49.                     echo ' - '; comments_popup_link(); echo ' '; twentyseventeen_edit_link();
  50.                     echo categories_and_tags();                
  51.                 } else {
  52.                     echo twentyseventeen_time_link();
  53.                     echo ' - '; comments_popup_link();  echo ' '; twentyseventeen_edit_link();
  54.                     echo categories_and_tags();                
  55.                 };
  56.             echo '</div><!-- .entry-meta -->';
  57.         };
  58.  
  59.         if ( is_single() ) {
  60.             the_title( '<h1 class="entry-title">', '</h1>' );
  61.         } elseif ( is_front_page() && is_home() ) {
  62.             the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
  63.         } else {
  64.             the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
  65.         }
  66.         ?>
  67.     </header><!-- .entry-header -->
  68.  
  69.  
  70. /* ... twentyseventeen/template-parts/post/content.php ... */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top