Outputting all articles with a specific label

darryn soper's Avatar

darryn soper

23 Mar, 2010 02:32 AM via web

We have the labels listed as a sub-nav in the form of categories. When we click on a label, how do we show all blog articles assigned to that category?

  1. 2 Posted by John Nunemaker on 23 Mar, 2010 02:48 AM

    John Nunemaker's Avatar

    You can loop through the posts variable that automatically gets injected into the template.

    {% for post in posts %}
      {{ post.title }}
    {% endfor %}
    
  2. John Nunemaker closed this discussion on 23 Mar, 2010 02:48 AM.

  3. darryn soper re-opened this discussion on 23 Mar, 2010 03:09 AM

  4. 3 Posted by darryn soper on 23 Mar, 2010 03:09 AM

    darryn soper's Avatar

    How does this limit it to specific labels?

  5. 4 Posted by Galen King on 23 Mar, 2010 03:12 AM

    Galen King's Avatar

    Hi John,

    That was actually me posting those queries at Darryn's desk.

    What we want to do is something like this (semi-pseudo code):

    {% for post in current_label.posts %}
    do stuff
    {% endfor %}
    

    Cheers,

    Galen

  6. 5 Posted by John Nunemaker on 23 Mar, 2010 03:20 AM

    John Nunemaker's Avatar

    Yes, if you are viewing a label, ie: blog/labels/foo then posts is a
    variable that is automatically injected in. It is only the posts that have
    that label. Did you try the snippet? If you have blog.label template and
    that is assigned to each label, posts is automatically made available for
    you.

    We need to document this a bit better. Does this answer you question?

  7. 6 Posted by Galen King on 23 Mar, 2010 03:40 AM

    Galen King's Avatar

    #resolve

    Yes, perfect. Thanks.

    Galen

    Sent from my iPhone

  8. John Nunemaker closed this discussion on 11 May, 2010 04:51 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

17 May, 2012 10:45 PM
20 Mar, 2012 05:05 PM
26 Apr, 2012 01:40 AM
07 Mar, 2012 04:42 PM