Make parent categories not selectable

I really doubt this is filterable, so jQuery comes to rescue 🙂 The Code add_action( ‘admin_footer-post.php’, ‘wpse_22836_remove_top_categories_checkbox’ ); add_action( ‘admin_footer-post-new.php’, ‘wpse_22836_remove_top_categories_checkbox’ ); function wpse_22836_remove_top_categories_checkbox() { global $post_type; if ( ‘post’ != $post_type ) return; ?> <script type=”text/javascript”> jQuery(“#categorychecklist>li>label input”).each(function(){ jQuery(this).remove(); }); </script> <?php } The Result Advanced There’s a caveat: whenever selecting a sub-category, it … Read more

How to hide a specific category posts in my monthly archive?

There are two ways of doing it: You can use a filter to alter the query when viewing an archive page. You will need to find the ID of your category ‘blogs’ (you can obtain it from the slug using get_term_by). Alternatively you can exclude a particular category by ID. add_action( ‘pre_get_posts’, ‘my_change_query’); function my_change_query($query){ … Read more

Different templates for parent and children categories/taxonomies

I suggest creating 3 files 1) regiontemplate-country.php 2) regiontemplate-city.php These 2 will contain the templates for country & city, then 3) taxonomy-region.php In this file, add the code to load the appropriate template <?php $term = get_term_by(‘slug’, get_query_var(‘term’), ‘region’); if((int)$term->parent) get_template_part(‘regiontemplate’, ‘city’); else get_template_part(‘regiontemplate’, ‘country’);

Exclude sub category posts from category display

I rewrote the code from a post at WP Engineer: function wpse_filter_child_cats( $query ) { if ( $query->is_category ) { $queried_object = get_queried_object(); $child_cats = (array) get_term_children( $queried_object->term_id, ‘category’ ); if ( ! $query->is_admin ) //exclude the posts in child categories $query->set( ‘category__not_in’, array_merge( $child_cats ) ); } return $query; } add_filter( ‘pre_get_posts’, ‘wpse_filter_child_cats’ ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)