• How do I show only one category in an Archives page? I want all the posts from that category to be displayed as in the MonthArchives hack/plug-in, so it would be by year, then listed by month.

Viewing 1 replies (of 1 total)
  • Well, you could modify the query in

    wp-content/plugins/montharchive.php

    on or about line 33 (I have v 0.1):
    $query = mysql_query(“SELECT *, year(post_date) as year, month(post_date) as month FROM $tableposts WHERE year(post_date)=’$year’ AND month(post_date)=’$date[month]’ ORDER BY id desc”) or die(mysql_error());

    You can add

    AND post_category=#

    where post_category is the number of the category, which you can find in the wp_categories table. So, for instance, if you want only the category “General” you’d do the following in your database to find the #:

    select cat_ID from wp_categories where cat_name=”General”;

    The result, in my case, is 1. (not surprising)

    So I’d change the query to:
    $query = mysql_query(“SELECT *, year(post_date) as year, month(post_date) as month FROM $tableposts WHERE year(post_date)=’$year’ AND month(post_date)=’$date[month]’ AND post_category=1 ORDER BY id desc”) or die(mysql_error());

    Hope this is helpful, I was looking for a different question/answer and found this one.

Viewing 1 replies (of 1 total)
  • The topic ‘Show only one category in Archives’ is closed to new replies.