category_count gives wrong number of posts in category

I don’t know if your issue is cached values at all, but get_category() does cache results, so it’s a possibility. Here are some other options: $current_cat_id = get_query_var(‘cat’); $category = get_category($current_cat_id); // One possibility: $count_a = get_category_count( $category->slug ); // OR… another possibility: $count_b = wp_count_terms( $category->slug );

sub-category showing up in wrong order in breadcrumbs

As you said, you’ve a category (parent one) named as Oregon and its sub-category ‘Southern’, therefore, Oregon / Southern is the correct output. It seems others are in wrong order. If Oregon is parent for Willamette Valley and Central then the result should be: Oregon / Central Oregon / Willamette Valley Consider what hierarchy you … Read more

Taxonomy page wpml dropdown not working

The default language selector is pretty crap TBH. I created this function using jQuery, you will have to amend to fit your template. function language_selector(){ $languages = icl_get_languages(‘skip_missing=0&orderby=code’); $current_lang = ICL_LANGUAGE_CODE; if(!empty($languages)) { ?> <div id=”language_list”> <div class=”current”> <img src=”https://wordpress.stackexchange.com/questions/95978/<?php bloginfo(“url’); ?>/wp-content/plugins/sitepress-multilingual-cms/res/flags/<?php echo ICL_LANGUAGE_CODE; ?>.png” alt=”<?php echo ICL_LANGUAGE_NAME; ?>” /> <?php echo ICL_LANGUAGE_NAME; ?> <i … Read more

Sorting past events by month

Using query_posts is pretty much always a bad idea as it causes another database query but it also will break pagination and can cause other issues as well. What you need it a filter on pre_get_posts. function pgp($qry) { if (!is_admin() && is_main_query() && $qry->is_category(3709)) { $qry->set(‘orderby’,’meta_value’); $qry->set(‘meta_key’,’Deadline’); //formatted YYYYMMDD $qry->set(‘ignore_sticky_posts’,true); } return $qry; } … Read more

Extract post category except one category

You can simply loop over the categories that you don’t need. get_the_category() return an array of categories that the post belongs to. With that in mind, you can do the following: (Just remember to change 21 and 41 to your desired ID’s) $categories = get_the_category(); foreach ( $categories as $category ) { if( 21 === … Read more