How to add css class to current menu item in WordPress ?

If you want to add css class to current menu item in WordPress. add_filter(‘nav_menu_css_class’ , ‘rs_special_nav_class’ , 10 , 2); function rs_special_nav_class ($classes, $item) { if (in_array(‘current-menu-parent’, $classes) ){ $classes[] = ‘active-item’; } if (in_array(‘current-menu-item’, $classes) ){ $classes[] = ‘active-item’; } return $classes; }

How to show subcategory inherit the parent category template in WordPress ?

If you want to show subcategory posts in parent category template then you have to include below code in functions.php file. function rs_subcategory_hierarchy() { $category = get_queried_object(); $parent_id = $category->category_parent; $templates = array(); if ( $parent_id == 0 ) { // Use default values from get_category_template() $templates[] = “category-{$category->slug}.php”; $templates[] = “category-{$category->term_id}.php”; $templates[] = ‘category.php’;

Exclude specific category, post, page from Search in WordPress ?

If you want to exclude a specific category or post or page then you have to put the id in below code. function exclude_category_search( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( $query->is_search ) { $query->set( ‘post__not_in’, array( 668,5004,5409,5407,4392,5416,500,502,3817,3819,4708,671) ); $query->set( ‘cat’, ‘-3625,-40’ ); } } add_action( ‘pre_get_posts’, ‘exclude_category_search’, 1

How can you change the version of style.css in WordPress theme?

If you need to change your style.css or any css file after the file edited or modified in wordpress theme then you need to add this code in your functions.php file. if(!is_admin()) wp_enqueue_style( ‘stylesheet-id’, get_stylesheet_directory_uri() . ‘/style.css’, array(), filemtime( get_stylesheet_directory() . ‘/style.css’ ) ); ‘stylesheet-id‘ this id is important please keep in mind if you