WordPress.org

Ready to get started?Download WordPress

Forums

how to display all tags in one page??? (11 posts)

  1. softsoft
    Member
    Posted 5 years ago #

    i need to display all my blog tags in one page.
    can i find a plugin for that.

  2. Dgold
    Member
    Posted 5 years ago #

    Make a new page template for your theme, and put this in the template:

    <?php wp_tag_cloud(''); ?>

    More info here:
    http://codex.wordpress.org/Template_Tags/wp_tag_cloud

    Or, write a New Page, and put that code in the content of the page. Then, I think, you might need a plugin like RunPHP or PHPexec so that the PHP code can run from inside your post. I'm not sure if this type of plugin is still needed in WP, seems like someone said WP can run PHP in posts without a plugin?

  3. softsoft
    Member
    Posted 5 years ago #

    <?php wp_tag_cloud(''); ?>

    this code is displaying a few tags "45 of 1570" can i get the code that display all tags.

  4. softsoft
    Member
    Posted 5 years ago #

    can someone help please?

  5. Dgold
    Member
    Posted 5 years ago #

    Try something like this
    <?php wp_tag_cloud('number=0'); ?>

    or see the difference when you put this
    <?php wp_tag_cloud('number=0&orderby=count'); ?>

    or compare this,
    <?php wp_tag_cloud('number=0&order=RAND'); ?>

    On the link I posted above, it tells us:

    Parameters
    (integer) The number of actual tags to display in the cloud. (Use '0' to display all tags.)

  6. Dgold
    Member
    Posted 5 years ago #

    I created a guide for integrating Tags into your theme including putting tags in single post pages, complete Tag archives for a comprehensive index of your tags, and tag pages for each tag showing all the posts that have that tag assigned.

    Try this out if you like! You will have to dig in the dirt a little for this but it is do-able if you know a little about WordPress page templates and the template hierarchy. Here we go.

    STEP 1
    Put this in your theme's functions.php file

    // total number of tags
    function tagstats() {
              global $wpdb;
              global $numtags;
              $wp_test = get_bloginfo ('version');
              $numtags = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = 'post_tag'");
              if (0 < $numtags) $numtags = number_format($numtags);
              echo $numtags . '';
    }

    STEP 2
    Then make a new page template called something like tags-archive.php and use this in it: ((or just put this directly in the contents body of a new page if you can run php in a post, plugins like RunPHP allow this))

    <h3>Random remix tag cloud:</h3>
    <?php wp_tag_cloud('number=50&format=list&order=RAND'); ?>
    
    <h3>Most common tags:</h3>
    <?php wp_tag_cloud('number=50&format=list&orderby=count'); ?>
    
    <h3>All <?php if (function_exists('tagstats')) { tagstats(); } ?> tags in alphabetical order:</h3>
    <?php wp_tag_cloud('smallest=10&largest=10&number=0&format=list'); ?>

    STEP 2B
    Go into WP-Admin > Page > Write New Page > make the new page title "Tag" or something like "Check Out All My Tags Here" and make the page slug "tag".

    STEP 2C
    On the new page you just created, under Page Templates drop-down menu, switch the template to the tags-archive.php template that you created in Step 2.

    STEP 3
    Then make or go into your theme's tag.php or archive.php and put this:

    <?php /* If this is a tag archive */ } elseif (is_tag()) { ?>
    		<h2 class="pagetitle">Archive for '<?php single_tag_title(); ?>' Tag</h2>
    <ul><li><a href="<?php bloginfo('url'); ?>/tag/">All <?php if (function_exists('tagstats')) { tagstats(); } ?> tags index here.</a></li></ul>

    STEP 4
    Put this somewhere in your theme's single.php :
    File under:</span> <?php if (the_category(', ')) the_category(); ?> <?php if (get_the_tags()) the_tags('<span class="post-meta-key">Tags: </span>',' | ',''); ?>

    • The result is cool. This gives you a count of the total number of tags you have assigned on your blog.
    • You get a section saying Filed under: Category 1, Category 2, Tag 1, Tag 2, Tag 3, Tag 4, on every Single Post page.
    • This gives you a Tags Archive Page, with the address of yoursite.com/tag/ and on that page you get 3 sections:
      1. A list of 50 tags in random order like a tag cloud
      2. + A list of the 50 most commonly used tags in sorted cloud like star wars letters
      3. + A comprehensive alphabetical index list of all the tags you have ever used on your blog, with a count showing the total number.
    • Finally, this gives you a Tag Page for every tag, so that when someone clicks on a Tag listed under a song they are taken to a special collection of posts associated with that tag.

    There are a million ways to modify this.

  7. Dgold
    Member
    Posted 5 years ago #

    I updated the above and took it another step further, better code, check here,
    http://wordpress.org/support/topic/230597?replies=3

    How I made Tag Archives and linked them up everywhere I wanted.

  8. softsoft
    Member
    Posted 5 years ago #

    thanks Dgold,
    it is working fine.

  9. bbkudk
    Member
    Posted 5 years ago #

    <?php
    
    function wp_get_all_tags( $args = '' ) {
    
      $tags = get_terms('post_tag');
      foreach ( $tags as $key => $tag ) {
          if ( 'edit' == 'view' )
              $link = get_edit_tag_link( $tag->term_id, 'post_tag' );
          else
              $link = get_term_link( intval($tag->term_id), 'post_tag' );
          if ( is_wp_error( $link ) )
              return false;
    
          $tags[ $key ]->link = $link;
          $tags[ $key ]->id = $tag->term_id;
          $tags[ $key ]->name = $tag->name;
    //      echo ' <a href="'. $link .'">' . $tag->name . '</a>';
          }
      return $tags;
    }
    wp_get_all_tags();
    
    ?>
  10. Rich Owings
    Member
    Posted 4 years ago #

    Dgold,

    I'm trying to implement this, and it does generate the archive page I'm after. But I get a syntax error when I click on a tag link. There seems to be a missing opening curly brace in the code you posted above (which I've pasted below). Can you clarify what the correct code is? I play at the PHP 101 level! Thanks for any help you can offer.

    <?php /* If this is a tag archive */ } elseif (is_tag()) { ?>
    		<h2 class="pagetitle">Archive for '<?php single_tag_title(); ?>' Tag</h2>
    <ul><li><a href="<?php bloginfo('url'); ?>/tag/">All <?php if (function_exists('tagstats')) { tagstats(); } ?> tags index here.</a></li></ul>
  11. Rich Owings
    Member
    Posted 4 years ago #

    Never mind. All I wanted was a page with a list of tags in alphabetical order, so all I needed was step 2. Which works great BTW!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.