Get the category from the query (2 posts)

  1. lobsterman
    Posted 9 years ago #

    I'm using query_posts() to filter a certain category out of the index page and monthly archives (to be used as 'asides')
    In the index page, i just use query_posts(), but in the monthly archives, I need to get the archive month from the query, and pass it to wp_query() so it will show the right category.
    How do I do this?
    I hope this makes sense...

  2. Kafkaesqui

    Posted 9 years ago #

    If you're using default permalinks on your blog (i.e. ?p=10), you can collect the global $m variable and pass that to query_posts:

    <?php query_posts("m=$m"); ?>

    For custom permalinking, try $year and $monthnum:

    <?php query_posts("year=$year&$monthnum=$monthnum"); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.