How to get count of posts in a particular category?

You can get get count of posts in a particular category by using below code. Before use please replace “CUSTOM_POST_TYPE” and “CUSTOM_TAXONOMY” with your post type and taxonomy.

$the_query = new WP_Query( array(
    'post_type' => 'CUSTOM_POST_TYPE',
    'tax_query' => array(
        array(
            'taxonomy' => 'CUSTOM_TAXONOMY',
            'field' => 'id',
            'terms' => TERM_ID
        )
    )
) );
$count = $the_query->found_posts;

Have any doubt please comment here.

Advance Happy New Year

As You Log Out Of Last Year
And Login To This New Year,
I Wish To Send You Happy New Year Wishes
Full Of Success, Prosperity, Happiness And Joy.
May This Be A Year Of Change Unto Your Life
May God Give You Protection And Good Health
So That You Live To See Other Years To Come

Redirect non admin users to home page and disallow back end access in WordPress

For redirect non admin users to home page and disallow back end access in WordPress, you need to simply copy and paste the following code in your theme’s functions.php file.

function redirect_non_admin_user(){
    if ( !defined( 'DOING_AJAX' ) && !current_user_can('administrator') ){
        wp_redirect( site_url() );  exit;
    } 
}
add_action( 'admin_init', 'redirect_non_admin_user' );

Have any doubt, then comment here!