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 do you remove display of WooCommerce product category on single product page?

As an alternative to editing the meta template, you can prevent the meta information from being displayed on single product pages at all. This can be handy if you also don’t want to display the SKUs. Here is how to do it: remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_meta’, 40 ); It goes to your functions.php.

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

Get multidimensional array that reflects category hierarchy

So here is a function that can be used just like WordPress get_categories but returns a hierarchical array. For this there is a child_categories property added to each WP_TERM object: function get_categories_hierarchical( $args = array() ) { if( !isset( $args[ ‘parent’ ] ) ) $args[ ‘parent’ ] = 0; $categories = get_categories( $args ); foreach( … Read more

Custom page for WooCommerce’s /product-category/

product-category URL uses taxonomy-product-cat.php which calls archive-product.php you will need to override it by creating the same file with the same name in themefolder/woocommerce/archive-product.php You can open any file in templates folder in the WooCommerce plugin and you will find a line in the very top comment describes how to override the file. Don’t forget … Read more