Support » Fixing WordPress » Exclude Category from Recent Posts in sidebar

Viewing 6 replies - 1 through 6 (of 6 total)
  • Bump. I need this ASAP, I can’t put my site online because of this. Tried lots of stuff but still can’t do it.

    Looks like the SideBlog plugin might allow you to specify the categories that get published as asides.

    Read again my first post =P

    (Recent Posts isn’t Sideblog)

    Ok, found an approximation:

    <?php $temp_query = $wp_query; // save original loop ?>
    <?php query_posts("cat=-19&showposts=10"); // exclude the asides category and get the latest 10 posts ?>
    <?php while (have_posts()) : the_post(); ?>

    <li><a>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    <?php $wp_query = $temp_query; // revert to original loop ?>

    This should work, but gives me this error:

    WordPress database error: [Not unique table/alias: 'wp_post2cat']
    SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND 0=1 AND (category_id != 19) AND post_date_gmt <= '2006-05-12 13:54:59' AND (post_status = "publish" OR post_author = 1 AND post_status != 'draft' AND post_status != 'static') AND post_status != "attachment" AND category_id != 19 GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10

    If I remove the ‘-‘ of ‘-19’ the first code thing works, but of course I don’t want to show that category, and I know that I cannot include more than one category when query_posts is used.

    OMG I did broke the layout =P

    Customizable Post Listings to the rescue! I could do this after long hours with one of my favorite plugins =)

    Plugin: Customizable Post Listings

    The winner:

    <?php c2c_get_recent_posts(7,"
    ", "1, 12, 13, 14, 15, 16, 17, 18"); ?>

    As you see, I must now add the categories manually, which is a damn hassle, but at least works.

    It would have been SO MUCH easier if get_archives had an option to exclude categories…

    I posted a reply on this subject in another thread.

    This works for me. I use it for exactly the same purpose: not showing my Asides titles in my Recent posts lists.

    The code looks like Stahns code above, but is not exactly the same.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Exclude Category from Recent Posts in sidebar’ is closed to new replies.