Category slug in in loop always the same?

First, Please don’t use query_posts.. Second, you’ve set $category somewhere in code not posted and never change it. How do you expect it to be different? What you need to do is retrieve the categories, which isn’t that hard… $cq = new WP_Query(‘category__in=4′); while ( $cq->have_posts() ) { $cq->the_post(); $c = wp_get_object_terms($post->ID,’category’); var_dump($c); // echo … Read more

Printing direct descendants of a category with WP_Query

From the Codex: child_of (integer) Display all categories that are descendants (i.e. children & grandchildren) of the category identified by its ID. There is no default for this parameter. If the parameter is used, the hide_empty parameter is set to false. And… parent (integer) Display only categories that are direct descendants (i.e. children only) of … Read more

AZ Directory category

I wrote a tutorial on Creating an Alphabetical Glossary of Posts but here are the most relevant parts. First create a hidden taxonomy for the letters of the alphabet // Add new taxonomy, NOT hierarchical (like tags) function kia_create_glossary_taxonomy(){ if(!taxonomy_exists(‘glossary’)){ register_taxonomy(‘glossary’,array(‘post’),array( ‘show_ui’ => false )); } } add_action(‘init’,’kia_create_glossary_taxonomy’); Then when any post is saved, save … Read more

How to create a category or tag available exclusively to the admins and not to the users?

Sure, you can restrict access to a tag with the following code: add_action(‘save_post’, ‘remove_tags_function’, 10, 2); function remove_tags_function( $post_id ){ if(!current_user_can(‘manage_options’)){ $post_tags = wp_get_post_terms( $post_id, ‘post_tag’, array( ‘fields’=>’names’ ) ); $pos = array_search( ‘ExclusiveContent’, $post_tags ); if( false !== $pos ) { unset( $post_tags[$pos] ); wp_set_post_terms ($post_id, $post_tags, ‘post_tag’); } } } So, with this … Read more

Category base 404 – fix

Yes, there is such way. To be precise, there are many ways to accomplish that. You can add ‘Category’ page. Make sure that its slug is set to ‘category’. If you go to example.com/category/ then this page will be shown. If there were no custom changes to rewrite rules, then WordPress will first try to … Read more