Show article tags

Hi, I can’t show the article tags. I would like the date, categories and tags to be displayed in the articles.

Thank you

Hello Frankie,

Thanks for writing in!

The date, categories and tags are the post meta as we call it. You can enable them by going to X > Theme Options > Blog > Content > Post Meta option.

If you need anything else we can help you with, please let us know.

Thank you @RueNel,

but I have already changed the settings of the theme and I have also added the code in functions.php to show only the date, categories and tags (I found the functions on this blog).
Now, in the posts I only see the date and categories, not the tags. How can I do that?

I copy the code below:

// Entry Meta
// =============================================================================

if ( ! function_exists( 'x_ethos_entry_meta' ) ) :
  function x_ethos_entry_meta() {

    //
    // Date.
    //

    $date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar fa-lg" data-x-icon="&#xf073;"></i> %2$s</time></span>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
    );


    //
    // Categories.
    //

    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: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                              . '"> '
                              . $category->name
                              . '</a>'
                              . $separator;
        }

       $categories_list = sprintf( '<span class="entry-categories"><i class="far fa-bookmark fa-lg" data-x-icon="&#xf02e"></i> %1$s',
        trim( $categories_output, $separator )
      );
      } else {
        $categories_list = '';
      }
    } else {
      $categories        = get_the_category();
      $separator         = ', ';
      $categories_output = '';
      foreach ( $categories as $category ) {
        $categories_output .= '<a href="'
                            . get_category_link( $category->term_id )
                            . '" title="'
                            . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                            . '"> '
                            . $category->name
                            . '</a>'
                            . $separator;
      }

      $categories_list = sprintf( '<span class="entry-categories"><i class="far fa-bookmark fa-lg" data-x-icon="&#xf02e"></i> %1$s',
        trim( $categories_output, $separator )
      );
    }

  //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: &ldquo;%s&rdquo;", '__x__' ), $tag->name ) )
                            . '"> '
                            . $tag->name
                            . '</a>'
                            . $separator;
      }

      $tags_list = sprintf( '<span>%3$s',
        __( ' Tags:', '__x__' ),
        trim( $tags_output, $separator )
      );
    
    }


    //
    // Output.
    //

    if ( x_does_not_need_entry_meta() ) {
      return;
    } else {
      printf( '<p class="p-meta">%1$s%2$s%3$s</p>',
        $date,
		$categories_list,
		$tags_list
      );
    }

  }
endif;

Hi Frankie,

Do you mean you wish to remove tags or display it? Because the tag listing is already part of the code you have provided. If you wish to remove it then you can simply change this code block

printf( '<p class="p-meta">%1$s%2$s%3$s</p>',
        $date,
		$categories_list,
		$tags_list
      );

to this

printf( '<p class="p-meta">%1$s%2$s</p>',
        $date,
		$categories_list
      );

But if you mean that you wish to display the tags but it’s not displaying, then would you mind providing a sample URL where we can check it? In the meantime, I recommend adding tags to that post if it’s empty.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.