Custom Nav Walker menu – Display category count

I think you should probably use wp_list_categories(), which even has parameters for a count, like e.g. show_count and pad_counts. Additionally it supports custom walkers via the walker parameter, but the walker would be based on Walker_Category – source -, which gives you every additional styling option you want.

Delete a specific category when deleting a user

delete_user action involves two parameters: $id and $reassign. So you should specify two parameters for the hook. Because sanitize_term() and sanitize_user() use different ways to sanitize strings, ‘tips_’ . $_POST[‘user_login’] and ‘tips_’ . $user_obj->user_login are not always the same string. So it’s better to use ‘tips_’ . sanitize_user($_POST[‘user_login’) as term name when inserting the term.

WP_Query not looking at child category

You’ll have to get the child or parent categories yourself and pass all the IDs as an array via the category__in argument of WP_Query. You can use get_ancestors to get the top parent category, and get all child categories of that parent via the child_of argument of get_categories.

Rearranging posts based on categories

May be it’s a bad idea, but it’s the only. Don’t print posts immediately, but collect them in different variables: one for category “test”, one for the rest. <?php $w_h = $w_d = $last = 0; // init variables to concatenate content later $primary_posts = $secondary_posts=””; // empty array to fill later $category_names = array(); … Read more

is_category() function

My suspicion is that, for some reason, the name “51m series” or slug 51m-series is (or both are) matching is_category( 51 ). The is_category() function uses the PHP in_array() conditional to match against ID, slug, and name: if ( in_array( $cat_obj->term_id, $category ) ) return true; elseif ( in_array( $cat_obj->name, $category ) ) return true; … Read more

How to exclude uncategorized from permalink structure /%category%/%postname%/

I hope this will work for you 😀 function mf_post_link( $permalink, $post, $leavename ) { if( $post->post_type != ‘post’ ) return $permalink; // if no category, the filter is deactivated $cats = get_the_category($post->ID); if( ! count($cats) ) return $permalink; usort($cats, ‘_usort_terms_by_ID’); // order by ID $category_object = apply_filters( ‘post_link_category’, $cats[0], $cats, $post ); $category_object = … Read more