[resolved] Exclude specific category from specific author archive (4 posts)

  1. Paul Skip Brown
    Posted 2 years ago #

    Hi, I've been round in circles a bit tried various solutions on here and via Google search but not worked.

    I have an author 'Paul' - I have created a PHP file just for this author's archive called author-paul.php as per WordPress file hiarachy and it works fine. I would like to exclude category 92 from Paul's author archive. I guess I can add the code either directly in this PHP file or in the functions.PHP file.

    I tried editing <?php while ( have_posts() ) : the_post(); ?> to <?php query_posts('cat=-92'); while ( have_posts() ) : the_post(); ?> but it excludes more than just category 92.

  2. Paul Skip Brown
    Posted 2 years ago #

    So I think I finally figured it out. Can anyone explain why for future reference? The code I used was...

    <?php query_posts($query_string . 'cat=-92'); while ( have_posts() ) : the_post(); ?>

    instead of my original attempt...

    <?php query_posts('cat=-92'); while ( have_posts() ) : the_post(); ?>

  3. mores
    Posted 2 years ago #

    Your original attempt overwrote the query string, the second attempt added the category exclusion to the original query string.

  4. Paul Skip Brown
    Posted 2 years ago #

    Ah thank you mores - so the string ran as normal with the added exclusion. Perfect.

Topic Closed

This topic has been closed to new replies.

About this Topic