Custom Stylings for category pages

@EAMann has a great answer if you want different layouts for different categories. OTOH if you only want to change the CSS to, for example, have a different background color for each category then you’ll find that most themes will include the category slug as a CSS class on the <body> element and/or possibly other … Read more

Hide tag and category boxes from the post editor

Using remove metabox function you can do this. Simply put this inside your themes functions.php file at very end. NOTE – unwrap <?php ?> if necessary. <?php function wpse60590_remove_metaboxes() { remove_meta_box( ‘categorydiv’ , ‘post’ , ‘normal’ ); remove_meta_box( ‘tagsdiv-post_tag’ , ‘post’ , ‘normal’ ); } add_action( ‘admin_menu’ , ‘wpse60590_remove_metaboxes’ ); ?>

Default category link for a custom category is a broken link

I found that the reason flush_rewrite_rules(); wasn’t working was because switch_to_blog doesn’t re-initialize some of the properties of $wp_rewrite (not to mention other parts of WP), so flush_rewrite_rules was still generating some of the rules based on the permalink structure of the current blog (which is not the same), rather than the switched-to blog (84). … Read more

How to get product count with respect to categories in WooComerce

You just need to add $cat->count to get the count of all products in that category. Hope this helps you out. $args = array( ‘number’ => $number, ‘orderby’ => $orderby, ‘order’ => $order, ‘hide_empty’ => $hide_empty, ‘include’ => $ids ); $product_categories = get_terms( ‘product_cat’, $args ); foreach( $product_categories as $cat ) { echo $cat->name.’ (‘.$cat->count.’)’; … Read more

Replace category titles

Well thank you for this question i did this after you posted this function category_title( $title ){ if( is_category(‘name1’) ){ $title=”name1 title”; }elseif( is_category(‘name2’) ){ $title=”name2 title”; } return $title; } add_filter( ‘get_the_archive_title’, ‘category_title’ ); Hope this helps

If category is in parent category?

If i understand right your “post_is_in_descendant_category” function checks if a post is descendant of a category and you want to check if a category is descentand. If so the add this function to your functions.php function is_desc_cat($cats, $_post = null) { foreach ((array)$cats as $cat) { if (in_category($cat, $_post)) { return true; } else { … Read more

Make parent category not selectable when it has child categories

I disabled the parent boxes to avoid shifting parents to the left. add_action( ‘admin_footer-post.php’, ‘wpse_98274_disable_top_categories_checkboxes’ ); add_action( ‘admin_footer-post-new.php’, ‘wpse_98274_disable_top_categories_checkboxes’ ); /** * Disable parent checkboxes in Post Editor. */ function wpse_98274_disable_top_categories_checkboxes() { global $post_type; if ( ‘post’ != $post_type ) return; ?> <script type=”text/javascript”> jQuery( “#category-all ul.children” ).each( function() { jQuery(this).closest( “ul” ).parent().children().children( “input” ).attr( … Read more