List Categories By Specified First Character

global $wpdb; // In case it’s in a function… $parent = 0; // Change to dig deeper in tree $wpdb->query( <<<SQL SELECT t1.`term_id`, /* The ID */ t1.`name`, /* The name */ t1.`slug`, /* The slug */ t2.`parent`, /* The parent ID */ t2.`count` /* The item Count */ FROM {$wpdb->terms} AS t1, {$wpdb->term_taxonomy} AS … Read more

show only sub categories if available?

use a conditional statement, for example: $sub_cats = get_categories(‘parent=”.get_query_var(“cat’)); if( $sub_cats ) : //show list of child categories, for instance with wp_list_categories() echo ‘<ul>; wp_list_categories(‘title_li=&child_of=”.get_query_var(“cat’)); echo ‘</ul>’; //or possibly using $sub_cats and a foreach loop// 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>’; else: //the ‘normal’ LOOP of category.php// … Read more

Check boxes for showing categories

Although it looks like by default it has the categories as a dropdown select, it looks like this plugin could be slightly modified to fit your needs: Taxonomy Picker Taxonomy Picker is a widget which you can include in your sidebar to help visitors build complex queries using categories and your custom taxonomies by chosing … Read more

Category pagination not working

You should take a closer look at the [http://codex.wordpress.org/Template_Hierarchy Template Hierarchy]. From what I understood in your code is that you’re trying to list posts in the category where ID = 5. You can easily map that to the category-slug.php or category-id.php template files, so you won’t have to do any extra get_posts. The problem … Read more

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