<?php the_category() ?>
<?php
wp_list_categories('orderby=name&include=3,5,9,16'); ?>
<?php foreach((get_the_category()) as $cat) {
if (!($cat->cat_ID=='37')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. $cat->cat_name . '</a>' . ', ';
} ?>
Hide / Exclude Categories From Posts Page
<?php if (is_front_page() && !is_paged() )
$posts = query_posts($query_string . '&cat=-35'); ?>
<?php
$cat_to_exclude = 35;
query_posts($query_string . '&cat=-'.$cat_to_exclude');
?>
<?php if (in_category('35')) continue; ?>
or
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-5, -34' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );
Exclude Category from Homepage
Placing this code in your index.php file will cause your home page to display posts from all categories except category ID 3.
<?php
if (is_home()) {
query_posts("cat=-3");
}
?>
You can also add some more categories to the exclude-list(tested with WP 2.1.2):
<?php
if (is_home()) {
query_posts("cat=-1,-2,-3");
}
?>
or
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-3,-5,-23');
}
return $query;
}
add_filter('pre_get_posts', 'excludeCat');
<?php query_posts("cat=-25,35"); ?>
Look for this on your main theme index page:
<?php if (have_posts()) : ?>
Insert this right before (or above) it:
<?php query_posts('cat=-49'); ?>
Change the category ID to whatever it is you want to exclude.
<?php if (is_home()) {
query_posts($query_string . "&cat=-33");
} ?>
<?php if(is_home()) {query_post("cat=-39");}?php>
<?php
$excluded_cats = array( 44, 55 ); // ids to exclude
$args = array(
'caller_get_posts' => 1, // Don't show stickies at top
'posts_per_page' => 5, // The number of latest to show
'category__not_in' => $excluded_cats,
);
query_posts($args);
if(is_category()):// only run this on category page
$cc = get_queried_object();
$exclude = $cc->cat_name; //get the name of current category page
endif;
<?php
if(is_category()):// only run this on category page
$cc = get_queried_object();
$exclude = $cc->cat_name; //get the name of current category page
endif;
$categories = get_the_category();
foreach($categories as $category) :
if(is_category() && $category->name==$exclude)
continue; //skip current category from being displayed only on category pages
$category_link = get_category_link( $category->cat_ID );
echo '<li><a href="'.$category_link.'">'.$category->cat_name.'</a></li>';
endforeach;
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- If the post is in the category we want to exclude, we simply pass to the next post. -->
<?php if (in_category('3')) continue; ?>
<div class="post">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y'); ?></small>
<div class="entry">
<?php the_content(); ?>
</div>
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>