Exclude categories from postquery

You have missed a & before showposts in the query. Also showposts is depracated. Try using posts_per_page instead. <?php $gallery = get_cat_id(‘gallery’); $shirts = get_cat_id(‘shirts’); $hoodies = get_cat_id(‘hoodies’); $excluded_cats=”-“.$gallery.’,-‘.$shirts.’,-‘.$hoodies; $limit = 5; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts( ‘cat=” . $excluded_cats . “&posts_per_page=” . $limit . “&paged=’ . $paged ); $wp_query->is_category = true; … Read more

Last x Posted Categories?

<?php $cat_array = array(); $args=array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 20, ‘caller_get_posts’=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); $cat_args=array(‘orderby’ => ‘none’); $cats = wp_get_post_terms( $post->ID , ‘category’, $cat_args); foreach($cats as $cat) { $cat_array[$cat->term_id] = $cat->term_id; } endwhile; } if ($cat_array) { … Read more

Custom post type archive category page results in 404

Two things: You shouldn’t be using ‘category’ as a slug, since it’s already built into WP and thus is reserved (http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms) Pretending for a moment that it isn’t reserved, the base URL structure wouldn’t contain the post type in front of it. EDIT I just realized you didn’t set the archive slug itself. Instead of … Read more

Check for parent category

The correct syntax of cat_is_ancestor_of is cat_is_ancestor_of( $parent_cat_id, $child_cat_id ); Where: $parent_cat_id: should be the id to check if this is the parent category, in your case it should be 526. $child_cat_id: should be the id of the child category.

list all child categories that apply to current post even if those cats are empty?

get_the_category() get_categories() get_category_link() <?php echo ‘<ul>’; foreach(get_the_category() as $cat) { echo ‘<li><a href=”‘.get_category_link($cat->term_id).'”>’.$cat->name.'</a>’; $sub_cats = get_categories(‘parent=”.$cat->term_id.”&hide_empty=0’); if($sub_cats) { echo ‘<ul>’; foreach($sub_cats as $sub_cat) { echo ‘<li><a href=”‘.get_category_link($sub_cat->term_id).'”>’.$sub_cat->name.'</a></li>’; } echo ‘</ul>’; echo ‘</li>’; } } echo ‘</ul>’; ?> edit: for a list of sub categories in a category archive, try this code: <?php $cat = get_query_var(‘cat’); … Read more

Are tags different than categories?

This is indeed strange behaviour. The slug is a unique key in the table that stores taxonomy terms, if you make sure to explicitly set the slug to something different when you create the term, they will not be linked. However, once you’ve created a tag and a category with the same slug, it appears … Read more

WP Category Meta plugin fix? [closed]

take a look at wordpress taxonomies extra fields the easy way UPDATE: to get the data on the front end you can use the functions that come with the class ex: if (!function_exists(‘get_tax_meta’)) require_once(“path/to/Tax-meta-class/Tax-meta-class.php”); $saved_data = get_tax_meta($term_id,’field_id’); echo $saved_data;