Array: What is this value based on?
Use the php function unserialize() on that string and you will get a proper array. $cats = get_cats_from_database(); $cats = unserialize($cats); //now $cats is an array like Array(0 => 20, 1 => 343 );
Use the php function unserialize() on that string and you will get a proper array. $cats = get_cats_from_database(); $cats = unserialize($cats); //now $cats is an array like Array(0 => 20, 1 => 343 );
You can use the category__in parameter and that will do exactly what you’re looking for. Codex: WP_Query – Category Parameters
Check if $cat->category_parent != 1 (assuming uncategorized has the default ID of 1). If your subcategories are deeper than one level you’ll need to use get_ancestors to determine the top level category.
<?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; ?>
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() !?
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″>
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
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
as far as I know, all menu items already have unique ID´s (“menu-item-XX”), may they be first or second level. the UL itself has a different class : menu for first level and sub-menu for second. hence , in css for example .menu li and .sub-menu li will give you the differentiation for styling. you … Read more
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