'; } } add_action( 'wp_head', 'timesnews_pingback_header' ); // Default Category Lists for Dropdown if( !function_exists( 'timesnews_cat_list' ) ): function timesnews_cat_list() { $timesnews_args = array( 'type' => 'post', 'taxonomy' => 'category', ); $timesnews_cat_lists = get_categories( $timesnews_args ); $timesnews_cat_list = array('' => esc_html__('--Select--','timesnews')); foreach( $timesnews_cat_lists as $category ) { $timesnews_cat_list[esc_attr( $category->slug )] = esc_html( $category->name ); } return $timesnews_cat_list; } endif; //front page category list if( !function_exists( 'timesnews_frontpage_cat_list' ) ): function timesnews_frontpage_cat_list() { $timesnews_args = array( 'type' => 'post', 'taxonomy' => 'category', ); $timesnews_frontpage_cat_lists = get_categories( $timesnews_args ); foreach( $timesnews_frontpage_cat_lists as $category ) { $timesnews_frontpage_cat_list[esc_attr( $category->term_id )] = esc_html( $category->name ); } return $timesnews_frontpage_cat_list; } endif; //Exclude posts from home page function timesnews_exclude_homepage($query) { $front_page_categories = get_theme_mod('front_page_categories',''); if ( is_array( $front_page_categories ) && !in_array( 0, $front_page_categories ) ) { if ( $query->is_home() && $query->is_main_query() ) { $query->query_vars['category__in'] = $front_page_categories; } } } add_action('pre_get_posts', 'timesnews_exclude_homepage');