a-z list, categories and sub categories in loop

So you want to list the categories in a tree structure, in alphabetical order, showing ALL categories (even empty ones)? If so, try this: <?php $args = array(‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => false); $categories = wp_list_categories($args); ?> Reference: wp_list_categories

Multiple menu items highlighted

This question was also asked on stackoverflow. Here’s a copy of the answer i gave there: Perhaps you could style it using the nth-of-type CSS3 selector. .current-menu-item:nth-of-type(1) { background:#ffff00; /* Highlight styles */ } These styles would target only the first occurrence of the .current-menu-item. Likewise, you could choose to target the second with nth-of-type(2), … Read more

Show category children, one level

Why are you using the parameter parent=1? If you remove this parameter it should work. If you want children and grandchildren, you should use: $categories = get_categories(‘hide_empty=0&child_of=”.$cat); If you want only direct children, you should use: $categories= get_categories(“hide_empty=0&parent=”.$cat); Also note that you are echoing $mycat inside the loop, and you are joining the multiple categories … Read more

Edit the markup of categories list

List of possibilities You got exactly two options to alter the output of wp_list_categories() Use a filter after the MarkUp was generated and re-format it: add_filter( ‘wp_list_categories’, ‘wpse88292_reformat_list_cats’, 10, 2 ); function wpse88292_reformat_list_cats( $output, $args ) { // Reformat `$output` here // You can use `$args` to only this when condition X == Y return … Read more

How to find the number of Tags a post has?

for tags you can use $tags = get_tags(); $categories = get_categories(); $no_of_tags = count($tags); $no_of_categories = count($categories); refer this if you need more details : http://codex.wordpress.org/Function_Reference/get_tags http://codex.wordpress.org/Function_Reference/get_categories

Retrieve all posts within tag OR category?

You need a tax_query. $live_tags = array( ‘posts_per_page’ => 5, // showposts has been deprecated for a long time ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => ‘live’, ), array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => ‘candy’, ), ), ‘orderby’ … Read more

Sort posts by post_type in category.php template

Assuming your query does indeed have multiple post types, you’ll want to pluck them out before continuing (I assume you’re using $wp_query as your WP_Query object): <?php $all_post_types = array_map(function($item) { return $item->post_type; }, $wp_query->posts); // Now we get a unique list of post types: $unique_post_types = array_unique($all_post_types); // Use that unique list to drive … Read more

Single_cat_title() print the title before text

Set the display argument of the function to false. <h2> <?php if (is_category()){ echo ‘Category: ‘ . single_cat_title( ”, false); } ?> </h2> Or, to use the function in its more “helpful” form you could do: single_cat_title(‘Category: ‘); If the display argument is true, WordPress automatically echoes the content on to the page usually within … Read more