Show Category Name in Post
-
Hello:
I want to list the category name that a post is in at the top of the post. I need to exclude a couple of categories since some posts are in 2 or more categories. Here is what I started to use:
$cats = get_the_category($post->ID);
if ($cats) {
foreach($cats as $cat) {
if ($cat->cat_ID != 9) {
echo ‘<h4> cat_ID, ‘post_tag’ ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $cat->name ) . ‘” ‘ . ‘>’ . $cat->cat_name.’ </h4> ‘;
}
}
}The problem is I can’t figure out how to exclude categories from this. Any help is greatly appreciated!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Show Category Name in Post’ is closed to new replies.