Forums

A true tag index, all tags listed on a single page (3 posts)

  1. mattiem
    Member
    Posted 1 year ago #

    Greetings. I am looking for a way to create a page that lists out all tags on one page. Basically, I want a true tag index page for my site (not in the sidebar) that lists out all the various tags and how many associated posts there are with each tag.

    This would be very helpful for a blog that uses tags as ingredients in recipes ( see http://www.noveleats.com )

    Example:

    Tag1 (5) Tag4 (3)
    Tag2 (2) Tag5 (9)
    Tag3 (11) Tag6 (1)

    I don't know the best way to accomplish this, or even where to start. Any ideas to get me pointed in the right direction (or an existing solution) would be most helpful.

    Thanks!

  2. allyngibson
    Member
    Posted 1 year ago #

    That's actually very simple. What you want to do is to create a Tag archive page using a custom page template, but instead of making it a cloud, make it a list. :)

    There are some instructions here. Here's what I'd do.

    Make a copy of the page.php file in your theme. Call it tag-archive.php.

    Open the file. Find the line that reads at the top:
    <?php get_header(); ?>

    Replace that line with:
    <?php
    /*
    Template Name: Ingredients
    */

    get_header(); ?>

    Then find the line in that reads:
    <?php the_content();?>

    (It looks like you're running the Thesis theme, so you may have other stuff inside the parentheses. That's okay.)

    Replace that line with:
    <?php wp_tag_cloud('smallest=10&largest=10.5&format=list&number=5000&orderby=name'); ?>

    I'm taking a guess at the sizes. You can make the two numbers -- smallest and largest -- the same, but I don't recommend it; it causes a division-by-zero error in the code and the list comes out looking wonky.

    This won't give you the number after the tag's name, unfortunately; WordPress isn't set up to show that on the page. (Ironically, if you hover over the tag, I believe it does.)

    Save that file, upload it to your theme directory (or child directory, in your case). Create a new page, call it something like "Ingredients Index" or something like that, and select the Ingredients page template in the "Page Attributes" sidebar box on the page screen. You don't need to add any text to the content window; even if you do, it won't show. :)

    That should do it. If you get stuck (which you shouldn't), here's another example, here's one in the WordPress codex. It's really pretty quick and painless. :)

  3. mattiem
    Member
    Posted 1 year ago #

    Thanks so much for this detailed post (sorry I didn't respond sooner). I'm going to see if I can make this work. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic