Support » Fixing WordPress » How to exclude parent and child categories

  • Hi,

    I have a very very old WordPress site from which I need to exclude the parent and child categories until they are ready to make those posts available.

    I have imported a long list of posts and meta information via a CSV file so all the posts are in the site whilst they are working on adding images etc.

    Until we upgrade, this is how it needs to be but for now, I need to exclude the parent and child categories of the posts they just imported via this CSV.

    I have looked through a number of solutions none of which are working.

    This is my latest code…

    <?php while (have_posts()) : the_post(); ?>
    			<?php // here we exclude the parent and child categories. ?>
    			<?php if (!in_category('157')) { ?>
    				<div class="post">
    					<h1 id="post-<?php the_ID(); ?>">
    						<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    					<div class="descr">
    						<?php if(is_category() || is_archive())
    			<?php } ?>
    		<?php endwhile; ?>
    			<div class="left"><?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?></div>
    			<div class="clearer"><span></span></div>
    	<?php else : ?>
    			<h2 class="center">Not Found</h2>
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    	<?php endif; ?>

    Many thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Why don’t you just sort your posts in the post editor by this category and change their status?

    Hi Seacoast,

    In this very very old version of WordPress is there is no “select all” and change from “Uncategorized” to “Medical” option as there are in the latest versions of WP. It’s a super old version.

    I could run an SQL query to check for all all “Uncategorized” posts and then change the category based on this but the site has literally thousands of entries. And because I am new to the project, I don’t know how many other posts might be uncategorised, so I don’t want to take that chance.

    Perhaps there is a way for me to run an SQL query on a known date when I imported all the posts?

    Let me try that and see if that solves my problem, but in the meantime, if you have another solution, I am all ears.


    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler


    Okay, for starters there is not going to be a great deal of support (if any) for version 2.6. You need to upgrade (for many reasons, but security is number one). The reason none of the suggested fixes are working is that they’re probably all for later versions. And … yeah, no one’s going to want to delve that far back to suss out a fix just for an old version.

    I would select all your recent posts and make them draft, hiding them until you add images etc.

    Hi Mike,

    Thanks for getting back to me, I will look into the suggestion you have made.

    Chat soon

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to exclude parent and child categories’ is closed to new replies.