Viewing 5 replies - 1 through 5 (of 5 total)
  • hi

    I can’t guarantee the author-category combination will work since I haven’t tried it, but if it works it will look like this –

    query_posts('author=1&cat=-3,-6');

    where author=1 is the author id of the author, and cat=-3,-6 means exclude posts that are in those two category ID’s. a minus # on categories always means exclude.

    I suggest making a custom loop and putting it in the sidebar – this shows up to 5 posts. Note that if a post is in two categories and one is excluded and the other isn’t, the post will not be excluded.

    <h3>Recent Posts</h3>
        <ul>
        <?php
            $recentPosts = new WP_Query();
            $recentPosts->query('author=1&cat=-3,-6&posts_per_page=5');
        ?>
        <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
            <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
        <?php endwhile; ?>
        </ul>
    Thread Starter hbalagh

    (@hbalagh)

    i need it to show post from that particular author not just the admin’s so if im viewing a post by the name of adam it will show on the sidebar the last 5 post made from him or if im viewing post from susan it will show the last 5 of hers.. and so on

    Then try this. You must have double quotes on the query statement.

    <?php $authorID = get_the_author_meta('ID'); ?>
    <h3>Recent Posts</h3>
        <ul>
        <?php
            $recentPosts = new WP_Query();
            $recentPosts->query("author=$authorID&cat=-3,-6&posts_per_page=5");
        ?>
        <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
            <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
        <?php endwhile; ?>
        </ul>
    Thread Starter hbalagh

    (@hbalagh)

    thanks works great…now any clue of how to make it so it says recent post by authors name?

    Thread Starter hbalagh

    (@hbalagh)

    nevermind i really dont need it

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Post by author exclude categories’ is closed to new replies.