Small tip: exclude a category from your wordpress blog

First of all, let’s say we have a “Secrets” category, and we want to hide all the posts in this one from the blog.

Now, we have to find the ID of “Secrets”.

  1. Method 1:
    1. Log in to your wordpress blog and go to PostsCategories.
    2. Search for your category’s name.
    3. Look at the URL, there is the “tag_ID” param, for example tag_ID=250. So, the ID is 250.
  2. Method 2:
    1. mysql -u <user> -p <db>, insert your password
    2. Execute: select wp_terms.term_id from wp_terms, wp_term_taxonomy where wp_terms.name = “Secrets” AND wp_terms.term_id = wp_term_taxonomy.term_id AND wp_term_taxonomy.taxonomy = “category”;

Now, edit your theme’s index.php and search for the start of the loop:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Put this line just before:

<?php query_posts(‘cat=-250’); ?>

And that’s all.

 

Leave a Comment

Your email address will not be published.