WordPress.org

Forums

include a tag in category list ?? (2 posts)

  1. ApnaySMS
    Member
    Posted 5 years ago #

    include a tag in category list ??

    is there any way to show any tag along with Categories? ??
    with the same permalinks as category ?

    please help

  2. MichaelH
    Member
    Posted 5 years ago #

    <?php
    //list all categories and tags that are assigned to posts
    $types[0] = 'category';
    $types[1] = 'post_tag';
    
    foreach ($types as $type) {
      $taxonomy = $type;
      $terms = get_terms( $taxonomy, '' );
      if ($terms) {
        foreach($terms as $term) {
          if ($term->count > 0) {
            echo '<p>' . '<a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> has ' . $term->count . ' post(s). </p> ';
          }
        }
      }
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags