Support » Fixing WordPress » Exclude specific category from specific author archive

  • Resolved Paul Skip Brown

    (@paul-skip-brown)


    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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(); ?>

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

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude specific category from specific author archive’ is closed to new replies.