Hi!
Currently, every post on my blog has a postmeta-area above it, displaying the number of comments and the categories that the posted has been posted in using the_categories. You can see it in action here.
Obviously, this gets pretty messy when a post is included in a lot of categories. I was wondering whether it is possible to make sure that only a specific group of categories can be displayed above the post. For example, if a post is posted in "Filmer", "Electronic Arts" and "Nintendo DS", only "Nintendo DS" would appear.
Thanks in advance!
Exclude a category displaying under posts:
<?php
foreach((get_the_category()) as $category) {
if (!in_array($category->cat_name,array('cat1_to_exclude','cat2_to_exclude','cat3_to_exclude')) ) {
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
}
}
?>
Thanks! However, is there any way to change the code so I can specify what categories to include, as opposed to what categories to exclude? Seeing how my blog has a grand total of 67 categories, of which I would want to exclude 64.
if (in_array($category->cat_name,array('cat1_to_include','cat2_to_include','cat3_to_include')) ) {