Not showing list if there aren’t any categories to display

<?php $master_cat = get_category_by_slug( ‘Master’ ); $master_cat_id = $master_cat->term_id; $slave_cat = get_category_by_slug( ‘Slave’ ); $slave_cat_id = $slave_cat->term_id; $categories = wp_list_categories( ‘echo=0&show_option_none=&orderby=name&title_li=&exclude=”.$master_cat_id.”,’.$slave_cat_id ); if ( $categories ) : ?> <ul> <li><p>Categories:</p></li> <?php echo $categories ?> </ul> <?php endif; ?>

Functions.php: Exclude Category from “Blog”

http://codex.wordpress.org/Function_Reference/is_main_query add_action( ‘pre_get_posts’, ‘foo_modify_query_exclude_category’ ); function foo_modify_query_exclude_category( $query ) { if ( $query->is_main_query() && ! $query->get( ‘cat’ ) ) $query->set( ‘cat’, ‘-5′ ); } So it’s quite obvious to how exclude certain categories from within a template, … Actually it’s not. Are you talking about query_posts() !?

Problems with my conditionals in single.php by category

Look at http://codex.wordpress.org/Function_Reference/in_category Example: <?php if ( in_category(‘rabbis-weekly-commentary’) ) : ?> <div id=”inner_header”> <img src=”http://www.ifcj.ca/ifcj_ca/images/elements/commentary_header.gif” border=”0″> … <?php elseif ( in_category(‘yaels-weekly-commentary’) ) : ?> <div id=”inner_header”> <img src=”http://www.ifcj.ca/ifcj_ca/images/elements/commentary_header.gif” border=”0″>

How do I use just one category’ posts on my home page?

This should about do it for you, add args as needed $args = array( //basic post data ‘posts_per_page’ => 10, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, //category ‘category_name’ => ‘your-cat-slug’ ); $posts = new WP_Query( $args ); Docs: WP_Query

Change div background acording to the selected category

If you use wp_list_categories (see Codex), it automatically adds the classes cat-item,cat-item-{ID} and (to the current category being viewed) current-cat. (It also adds current-cat-parent to the parent of the current category). This should be enough to style any particular category a certain way, and style the current category a particlar way. However, you can obtain … Read more

Get post related on category

You can use WP_Query‘s tax_query to do this. You would want the args (just on the tax_query, I’ll leave the rest up to you, you have the documentation) to look something like this: ‘tax_query’ => array( ‘relation’ => ‘OR’ array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘wood’ ), array( ‘taxonomy’ => ‘category’, ‘field’ … Read more