true,
‘orderby’ => ‘count’,
‘order’ => ‘DESC’,
) );
$all_categories = array_filter( $all_categories, function ( $cat ) {
return strtolower( $cat->slug ) !== ‘uncategorized’;
} );
$categories = array_values( $all_categories );
// Homepage category selection from Theme Settings
$selected_cats = function_exists( ‘wph_get_setting’ ) ? wph_get_setting( ‘homepage_categories’, array() ) : array();
if ( ! empty( $selected_cats ) && is_array( $selected_cats ) ) {
$selected_cat_ids = array_map( ‘intval’, $selected_cats );
$filtered = array();
$cat_lookup = array();
foreach ( $categories as $cat ) {
$cat_lookup[ $cat->term_id ] = $cat;
}
foreach ( $selected_cat_ids as $cid ) {
if ( isset( $cat_lookup[ $cid ] ) ) {
$filtered[] = $cat_lookup[ $cid ];
} else {
$specific_term = get_term( $cid, ‘category’ );
if ( $specific_term && ! is_wp_error( $specific_term ) && strtolower( $specific_term->slug ) !== ‘uncategorized’ ) {
$filtered[] = $specific_term;
}
}
}
if ( ! empty( $filtered ) ) {
$categories = $filtered;
}
}
$homepage_title = function_exists( ‘wph_get_setting’ ) ? ( wph_get_setting( ‘homepage_h1_title’, ” ) ?: wph_get_setting( ‘homepage_h2_title’, ” ) ) : ”;
$homepage_desc = function_exists( ‘wph_get_setting’ ) ? wph_get_setting( ‘homepage_short_description’, ” ) : ”;
$wa_link = function_exists( ‘wph_get_setting’ ) ? wph_get_setting( ‘whatsapp_join_link’, ” ) : ”;
$tg_link = function_exists( ‘wph_get_setting’ ) ? wph_get_setting( ‘telegram_join_link’, ” ) : ”;
$yt_link = function_exists( ‘wph_get_setting’ ) ? wph_get_setting( ‘youtube_join_link’, ” ) : ”;
$ig_link = function_exists( ‘wph_get_setting’ ) ? wph_get_setting( ‘instagram_join_link’, ” ) : ”;
/* ── Helpers ────────────────────────────────────────────────────────── */
function wph_has_link( $url ) {
return ! empty( $url ) && $url !== ‘#’;
}
if ( ! wph_has_link( $wa_link ) && function_exists( ‘wph_get_setting’ ) ) {
$wa_link = wph_get_setting( ‘social_whatsapp’, ” );
}
if ( ! wph_has_link( $tg_link ) && function_exists( ‘wph_get_setting’ ) ) {
$tg_link = wph_get_setting( ‘social_telegram’, ” );
}
if ( ! wph_has_link( $yt_link ) && function_exists( ‘wph_get_setting’ ) ) {
$yt_link = wph_get_setting( ‘social_youtube’, ” );
}
if ( ! wph_has_link( $ig_link ) && function_exists( ‘wph_get_setting’ ) ) {
$ig_link = wph_get_setting( ‘social_instagram’, ” );
}
$about_text = function_exists( ‘wph_get_setting’ ) ? wph_get_setting( ‘site_about_text’, get_bloginfo( ‘description’ ) ) : get_bloginfo( ‘description’ );
/* ── Helper to find category by slug or name keywords ───────────────── */
function wph_find_matching_category( $categories, $keywords ) {
if ( empty( $categories ) || empty( $keywords ) ) {
return null;
}
foreach ( $categories as $cat ) {
foreach ( (array) $keywords as $kw ) {
if ( stripos( $cat->slug, $kw ) !== false || stripos( $cat->name, $kw ) !== false ) {
return $cat;
}
}
}
return null;
}
$govt_cat = wph_find_matching_category( $all_categories, array( ‘govt’, ‘government’, ‘sarkari’, ‘police’, ‘railway’, ‘ssc’, ‘upsc’ ) );
$private_cat = wph_find_matching_category( $all_categories, array( ‘private’, ‘it-job’, ‘corporate’, ‘private-jobs’, ‘company’ ) );
$results_cat = wph_find_matching_category( $all_categories, array( ‘result’, ‘results’, ‘answer-key’, ‘cutoff’ ) );
$admit_cat = wph_find_matching_category( $all_categories, array( ‘admit’, ‘hall-ticket’, ‘admit-card’, ‘admit-cards’ ) );
/* ── Inline SVG icons ───────────────────────────────────────────────── */
$svg_check = ‘‘;
$svg_date = ‘‘;
?>
Find latest Government jobs, Private vacancies, Admit cards, Results, and Admission notifications.
‘count’,
‘order’ => ‘DESC’,
‘number’ => 9,
‘hide_empty’ => true,
) );
$trending_items = array();
if ( ! empty( $trending_tags ) && ! is_wp_error( $trending_tags ) ) {
foreach ( $trending_tags as $t_tag ) {
$trending_items[] = array(
‘name’ => $t_tag->name,
‘url’ => get_tag_link( $t_tag->term_id ),
);
}
} else {
// Dynamic fallback to top categories if tags are not yet assigned
$popular_cats = get_categories( array(
‘orderby’ => ‘count’,
‘order’ => ‘DESC’,
‘number’ => 8,
‘hide_empty’ => true,
) );
if ( ! empty( $popular_cats ) && ! is_wp_error( $popular_cats ) ) {
foreach ( $popular_cats as $p_cat ) {
if ( strtolower( $p_cat->slug ) === ‘uncategorized’ ) continue;
$trending_items[] = array(
‘name’ => $p_cat->name,
‘url’ => get_category_link( $p_cat->term_id ),
);
}
}
}
?>
‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 6,
‘ignore_sticky_posts’ => true,
) );
if ( $latest_jobs_query->have_posts() ) :
?>
‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 6,
‘ignore_sticky_posts’ => true,
);
if ( $govt_cat ) {
$govt_args[‘cat’] = $govt_cat->term_id;
} else {
$govt_args[‘meta_query’] = array(
array(
‘key’ => ‘_wph_job_job_type’,
‘value’ => ‘Government’,
‘compare’ => ‘=’,
),
);
}
$govt_query = new WP_Query( $govt_args );
// Fallback if no specific govt posts yet
if ( ! $govt_query->have_posts() ) {
$govt_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘posts_per_page’ => 6,
‘offset’ => 0,
) );
}
// Private Jobs Query (6 Posts)
$private_args = array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 6,
‘ignore_sticky_posts’ => true,
);
if ( $private_cat ) {
$private_args[‘cat’] = $private_cat->term_id;
} else {
$private_args[‘meta_query’] = array(
array(
‘key’ => ‘_wph_job_job_type’,
‘value’ => ‘Private’,
‘compare’ => ‘=’,
),
);
}
$private_query = new WP_Query( $private_args );
// Fallback if no specific private posts yet
if ( ! $private_query->have_posts() ) {
$private_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘posts_per_page’ => 6,
‘offset’ => 6,
) );
}
?>
have_posts() ) : ?>
have_posts() ) : ?>
‘post’,
‘post_status’ => ‘publish’,
‘cat’ => $results_cat->term_id,
‘posts_per_page’ => 5,
‘ignore_sticky_posts’ => true,
) );
}
if ( ! $res_query || ! $res_query->have_posts() ) {
$res_tag = get_term_by( ‘slug’, ‘result’, ‘post_tag’ ) ?: get_term_by( ‘slug’, ‘results’, ‘post_tag’ );
if ( $res_tag ) {
$res_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘tag_id’ => $res_tag->term_id,
‘posts_per_page’ => 5,
‘ignore_sticky_posts’ => true,
) );
}
}
if ( ! $res_query || ! $res_query->have_posts() ) {
$res_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘s’ => ‘Result’,
‘posts_per_page’ => 5,
‘ignore_sticky_posts’ => true,
) );
}
if ( ! $res_query || ! $res_query->have_posts() ) {
$res_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 5,
‘ignore_sticky_posts’ => true,
) );
}
// ── 2. Dynamic Admit Card Query ──────────────────────
$adm_query = null;
if ( $admit_cat ) {
$adm_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘cat’ => $admit_cat->term_id,
‘posts_per_page’ => 5,
‘ignore_sticky_posts’ => true,
) );
}
if ( ! $adm_query || ! $adm_query->have_posts() ) {
$adm_tag = get_term_by( ‘slug’, ‘admit-card’, ‘post_tag’ ) ?: get_term_by( ‘slug’, ‘hall-ticket’, ‘post_tag’ );
if ( $adm_tag ) {
$adm_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘tag_id’ => $adm_tag->term_id,
‘posts_per_page’ => 5,
‘ignore_sticky_posts’ => true,
) );
}
}
if ( ! $adm_query || ! $adm_query->have_posts() ) {
$adm_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘s’ => ‘Admit’,
‘posts_per_page’ => 5,
‘ignore_sticky_posts’ => true,
) );
}
if ( ! $adm_query || ! $adm_query->have_posts() ) {
$adm_query = new WP_Query( array(
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => 5,
‘offset’ => 2,
‘ignore_sticky_posts’ => true,
) );
}
$results_view_url = $results_cat ? get_category_link( $results_cat->term_id ) : home_url( ‘/?s=Result’ );
$admit_view_url = $admit_cat ? get_category_link( $admit_cat->term_id ) : home_url( ‘/?s=Admit+Card’ );
?>
term_id === $results_cat->term_id ) return false;
if ( $admit_cat && $c->term_id === $admit_cat->term_id ) return false;
return true;
} );
$other_cats = array_values( $other_cats );
if ( ! empty( $other_cats ) ) :
$cat_chunks = array_chunk( array_slice( $other_cats, 0, 6 ), 3 );
?>
array(
‘taxonomy’ => ‘category’,
‘field’ => ‘term_id’,
‘terms’ => $cat->term_id,
‘include_children’ => false,
),
),
‘posts_per_page’ => 5,
‘post_status’ => ‘publish’,
‘ignore_sticky_posts’ => true,
‘no_found_rows’ => true,
) );
?>