Forums

Tags Listed on a Page? (5 posts)

  1. mrtvlamp
    Member
    Posted 1 year ago #

    I have a ton of tags, and would like to have a page dedicated to them instead of taking up so much real estate in the sidebar. I don't want a "cloud", but simple alphabetical list, possibly in two columns.(I don't need, or want, the counts alongside the tags) Anyone know how I might be able to do this?

  2. MichaelH
    Volunteer
    Posted 1 year ago #

    <?php
    //list terms in a given taxonomy
    $taxonomy = 'post_tag';
    $term_args=array(
      'hide_empty' => false,
      'orderby' => 'name',
      'order' => 'ASC'
    );
    $tax_terms = get_terms($taxonomy, $term_args);
    ?>
    <ul>
    <?php
    foreach ($tax_terms as $tax_term) {
    echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
    }
    ?>
    </ul>
  3. mrtvlamp
    Member
    Posted 1 year ago #

    I'm completely ignorant of php. I tried creating a page template using that code, and it does indeed bring up the tag list, but only the list. I don't know how to apply the code so that the header, sidebar, and all the other components of a page appear. I guess I'm just over my head. Thanks for the help.

  4. MichaelH
    Volunteer
    Posted 1 year ago #

    Copy your index.php to page.php, delete any loop code there, then add that code.

    For the TwentyTen theme the Page Template would look like:

    <?php
    /**
     * Template Name: My Page of Tags
     *
     * Selectable from a dropdown menu on the edit page screen.
     *
     * @package WordPress
     * @subpackage Twenty Ten
     * @since 3.0.0
     */
    ?>
    
    <?php get_header(); ?>
    
    		<div id="container">
    			<div id="content">
    
    <?php
    //list terms in a given taxonomy
    $taxonomy = 'post_tag';
    $term_args=array(
      'hide_empty' => false,
      'orderby' => 'name',
      'order' => 'ASC'
    );
    $tax_terms = get_terms($taxonomy, $term_args);
    ?>
    <ul>
    <?php
    foreach ($tax_terms as $tax_term) {
    echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
    }
    ?>
    </ul>
    
    			</div><!-- #content -->
    		</div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  5. mrtvlamp
    Member
    Posted 1 year ago #

    Wow, that worked!!! Where would I apply style changes to the links? (I'd like for the listed tags to not be underlined)
    Thank you so much!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags