Support » Fixing WordPress » Excluding categories in monthly archives

  • I have a category whose posts I would like to be only accessible by browsing the category itself.

    In order to do this, I’ve excluded it from the home page and the archive pages using this code:

    <?php if ( is_home() OR is_date() ) {
    } ?>

    Unfortunately, this breaks my monthly archive pages such that looking at August, for example, doesn’t show JUST August, it shows all posts (it acts like the home page).

    What can I do to fix this?

    Thank you!

Viewing 1 replies (of 1 total)
  • Get ready for a more complicated coding bit than what you have above. This is a modification of what I use on my site:

    <?php if(is_home() || is_date()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    if($year) $archive_arg = "&year=$year";
    if($monthnum) $archive_arg .= "&monthnum=$monthnum";
    if($day) $archive_arg .= "&day=$day";
    query_posts("paged=$paged" . $archive_arg);
    } ?>

    This should not only handle archive queries correctly, but allows for pagination (next/previous posts). Note to others: this only works for a blog using custom (date) permalinks.

Viewing 1 replies (of 1 total)
  • The topic ‘Excluding categories in monthly archives’ is closed to new replies.