Support » Themes and Templates » Required tag functions in 2.3 missing

  • I was sort of expecting WP 2.3 would include helper functions and conditional tags for the new tagging system. Things like is_tag() to determine whether the current page is a tag archive. Also a function like get_the_tag or something like that for getting the tag in question.

    The reason I’m asking about this is that I’d like to design the tag loop page to show a title of “Tag archive for ..”.

    Are those functions planned for another WP iteration?

Viewing 11 replies - 16 through 26 (of 26 total)
  • Yeah, Jeremy as it is, it’s not very clear.

    Otto: is there a sample tag.php page we could have a look at? The themes that come with the default install don’t provide one, which is suprising.

    (I must be doing something wrong cause I still get blank pages.)

    @otto42: That works!

    How would I display only the posts tagged with one particular tag?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Otto: is there a sample tag.php page we could have a look at? The themes that come with the default install don’t provide one, which is suprising.

    Like I said, this stuff is new. 🙂

    However, the default theme for 2.3 does include special code for tags. It does it by using is_tag() in the archive.php template, which is admittedly not the best way to demonstrate things. I should split that up into separate bits to provide a better idea. Maybe it’ll make it into the next version. 🙂

    Generally speaking, copy your theme’s index.php file to tag.php. Add some text to it, like “This is a Tag Archive”. Voila. You’ll get that when you click on any tag.

    All template pages are basically the same. Put in a Loop, it’ll display the associated posts for your tags/categories/archives/dates/whatever you’re getting.

    On my home page (home.php), I’d like to display 3 lists of recent post, each with different tags. (i.e. left column = x recent posts tagged ‘XXXX’, mid = x recent tagged ‘YYY’, right = x recent tagged ‘ZZZ’). How would I accomplish this?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    ix4li: It’s basically the same way you’d do it with categories. A separate query for each set.

    query_posts($query_string . "&tag=XXXX");
    // Do a Loop
    query_posts($query_string . "&tag=YYYY");
    // Do a Loop
    query_posts($query_string . "&tag=ZZZZ");
    // Do a Loop

    Around each Loop, you’d put your divs and such to make them go into columns or wherever else you want them on the page. And if you were displaying normal posts afterwards, you’d need to reset the query to normal with:
    query_posts($query_string);

    Otto42: thanks, it worked! (I was doing something wrong in my code.)

    BTW: along with, get_query_var('tag');, single_tag_title(); works as well, no?

    Thanks again for your help.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Yeah, that would do it. I also noticed that get_query_var(‘tag_id’) will get the tag_id too. See, it’s new, not even I know all of them. 🙂

    So try these:
    Tag ID:
    $tag_id = get_query_var(‘tag_id’);

    Tag Name:
    $tag_name = single_tag_title();

    Tag Link:
    $tag_link = get_tag_link(get_query_var(‘tag_id’));

    Tag RSS Feed:
    $tag_feed = get_tag_feed_link(get_query_var(‘tag_id’));

    Hi!

    I’ve managed to create an tag archive. Now, I want to insert a link to the tag’s feed into the left sidebar of the archive page.

    I’ve added the following code:

    div class="archive_feed">
     <a href="<?php get_tag_feed_link(get_query_var('tag_id')); ?>/feed">RSS feed for this tag</a>
    </div>

    Unfortunately, the link does not work. When i click on it, I’m directed to the feed of my whole blog.

    What do I do wrong? Any ideas?

    I also want to count the posts that are filed under one tag. Suggestions?

    Any help is appreciated! THANKS!

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Try this instead:

    <div class="archive_feed">
     <a href="<?php echo get_tag_feed_link(get_query_var('tag_id')); ?>">
    RSS feed for this tag
    </a>
    </div>

    Thank you, Otto42.

    Works fine now.

    Do you have any idea how i can count / display the number of posts filed under one tag?

    nick’s last q about tag count covered here:

    http://wordpress.org/support/topic/143607

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘Required tag functions in 2.3 missing’ is closed to new replies.