WordPress.org

Ready to get started?Download WordPress

Forums

Trouble creating easy linked list of tags (20 posts)

  1. sortagourmet
    Member
    Posted 2 years ago #

    I know this should be simple but I feel like I've downloaded every type of widget and can only find ones that are sidebar savvy...

    I'm (eventually) going to have lots of posts with different tags on each one (so Asparagus, Poached Eggs, and Goat Cheese all tagged). I'd like to be able to create linked lists for those tags so there is an "Asparagus" section with a linked list underneath to all the recipes that have Asparagus tagged in them.

    Something like this: http://smittenkitchen.com/recipes/ but with less manual updating? It looks manually updated.

    Maybe I'm making it harder, or there's an easier way to organize them, if so feel free to share!

    URL: http://www.sortagourmet.com if you need it

  2. deepbevel
    Member
    Posted 2 years ago #

    alrighty, unless someone can think of a plugin (which I'm sure is out there) there's a few ways. If you specify the post category(ies)id(s) in this code, it will return all the tags from those categories (or category) in a linked list without duplication.
    pastebin
    you'll use it outside the loop in a page template, or make a custom template just for this.
    Should also work in a php widget, if you should change your mind about that.

  3. deepbevel
    Member
    Posted 2 years ago #

    if you use it outside the loop in a page template for your theme, wrap it in:

    <?php if (is_page('page-slug')) { ?>
    
    code goes here	
    
    <?php } ?>

    just supply the page(slug) that you want it to appear on.

  4. sortagourmet
    Member
    Posted 2 years ago #

    First, thanks for the help :)

    I'm positive I'm putting this coding in on the wrong spot. I took the stuff out of paste bin that you sent, but I'm not sure exactly where to place it.

    Sorry I'm a bit novice, it's what happens when you put down coding for years.

    The list of things will be on a page, in the content section, not the sidebar if that helps.

    Of course, any help would be greatly appreciated.

  5. deepbevel
    Member
    Posted 2 years ago #

    I wouldn't know how to make it part of the actual content area, that's done in the page editor as far as I know.

    You have to place the code outside the loop, in a page template, no matter if custom or that of your theme.

    if you don't have any other content on the page that you added in the page editor, then your list will appear as though it is the content.

    if you want additional content on the page with your tag list, it will still show up, either above or below your tag list, depending on if you place the code before or after the loop.

    try it yourself first, place the code directly after "if have posts",
    or at the bottom of the page after directly after where it says "endif".

    If necessary, post your page code in pastebin and give me the link I'll show you.

    Good luck!

  6. raskull
    Member
    Posted 2 years ago #

    Without thinking too much, does your tag cloud widget (as displayed in a widgetized area like a sidebar), take you to a roundup of all posts tagged asparagus when you click on asparagus? if so, you are 90% there.

    What you want to do differently is
    display the tag terms in the main column in list format instead of in a sidebar in cloud format?
    and/or
    display the results of the clicked tag just as links to the post rather than post roundups or excerpts?

  7. deepbevel
    Member
    Posted 2 years ago #

    this is a round up, is not formatted correctlty for a page? i do indeed use it in a widget. but I figured a list is a list. what might be changed to improve it?

  8. raskull
    Member
    Posted 2 years ago #

    just looking at your site... I think if you just add some recipes it will become clearer to you how the whole thing works... functionally, everything you mention should happen automatically. from there, you might need to explore different themes or lift the hood to customize.

  9. deepbevel
    Member
    Posted 2 years ago #

    I think you are right, I only use this because it allows me to specify tags in specific categories. However it will also serve sortagourmet's purpose.

    And, actually it produces a list of all the post tiles that have the tag(s), as well as a link to the tag archive for each tag. So it kinda does it all, for a specific purpose I won't bother to explain. I intended to post similar code which only shows the links to each tag's archive, and not the post tiles. I'll do that soon!

  10. deepbevel
    Member
    Posted 2 years ago #

    Okay, this is wrong, sorry. it shows a linked list of all post titles (in a specific category) which share the same tag as the most recent post, a well as a link to that tag's archive! (whew) Yikes! sorry! I'll get back with what I intended asap if you're still unresolved.

  11. deepbevel
    Member
    Posted 2 years ago #

    at least if you get it to output where you want it you'll be that much further ahead. I'll be back.

  12. deepbevel
    Member
    Posted 2 years ago #

    this is it, it's basically like a tag cloud that allows you to specify a category.

    <?php
        global $post;
        query_posts ('cat=1 &posts_per_page=1'); ?>
      <?php if ( have_posts() ) : ?>
     <?php while (have_posts()) : the_post(); ?>
    
     <h4>
    <?php
    the_tags( __( ' ',
    ' ' ), ', ', '<br />'); ?> </p><?php
    $posttags = get_the_tags($post->ID);?>
    </h4>
        <?php endwhile; ?>
        <?php else : ?>
            <!-- html code if nothing found -->
        <?php endif; ?>
        <?php wp_reset_query();?>
    
    </ul>

    But as raskull say's if you just want a tag cloud for all categories as a list on a page, I think that's what a tag-template does. I suppose some themes have them, none that I've used do, or I never noticed.

  13. deepbevel
    Member
    Posted 2 years ago #

    that one shows duplicates, no good. This one is tried and true if still interested.

    here's a demo

  14. raskull
    Member
    Posted 2 years ago #

    If your theme doesn't have tag.php, the clicked tag will go to archive.php, filtered for your tag. If there is no archive.php, the clicked tag will go to index.php (your page for posts), filtered for your tag.

    Each of these templates serves the same purpose; but having all of them allows you to make a tag page look different than a category page look different than a news/blog/home page, etc.

    Check out the template hierarchy: http://codex.wordpress.org/Template_Hierarchy

    and the tag template:
    http://codex.wordpress.org/Tag_Templates

  15. deepbevel
    Member
    Posted 2 years ago #

    turns out my theme has a tag page after all, but it doesn't produce a list like the one in my demo, rather, it's what displays all the posts which share the tag.

  16. raskull
    Member
    Posted 2 years ago #

    I am thinking you -- or at least the original poster -- want to display all the posts that share a particular tag (correct me if I'm wrong). The issue is, do you want just the post title link to appear in the offerings, or the post title link and other details such as date, author, excerpt, etc. to appear? If so, then tweak templates.

    Otherwise... I think the original poster wants to offer access to all posts tagged "asparagus" (for example). That is what WordPress does in its sleep... Make post, tag post, go to sleep. Magic.

  17. deepbevel
    Member
    Posted 2 years ago #

    I thought they wanted a list of all tags, like a cloud, but on a page. so who knows.
    But I realize the output can me modified to include meta, or what ever.

  18. raskull
    Member
    Posted 2 years ago #

    ah, well, yes, we just need to get those tags on a page instead of in a sidebar. then magic...

  19. deepbevel
    Member
    Posted 2 years ago #

    I did it with my demo, the code is posted. It works!

  20. deepbevel
    Member
    Posted 2 years ago #

    there's also a plugin called widgets on pages. With that the OP can have any tag widget on a page. Might allow for more options and be easier.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.