tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support('title-tag'); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails'); add_image_size('post-img', 270, 207, true); add_image_size('large-img', 770, 463, true); add_image_size('article-thumb', 368, 216, true); add_image_size('feature-thumb', 1200, 532, true); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => esc_html__('Primary', 'stnews-theme'), 'footer-left' => esc_html__('Footer Left', 'stnews-theme'), 'footer-mid' => esc_html__('Footer Mid', 'stnews-theme'), 'footer-right' => esc_html__('Footer Right', 'stnews-theme'), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'stnews_theme_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); // Add theme support for selective refresh for widgets. add_theme_support('customize-selective-refresh-widgets'); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ add_theme_support( 'custom-logo', array( 'height' => 250, 'width' => 250, 'flex-width' => true, 'flex-height' => true, ) ); } endif; add_action('after_setup_theme', 'stnews_theme_setup'); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function stnews_theme_content_width() { // This variable is intended to be overruled from themes. // Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}. // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $GLOBALS['content_width'] = apply_filters('stnews_theme_content_width', 640); } add_action('after_setup_theme', 'stnews_theme_content_width', 0); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function stnews_theme_widgets_init() { register_sidebar( array( 'name' => esc_html__('Sidebar', 'stnews-theme'), 'id' => 'sidebar-1', 'description' => esc_html__('Add widgets here.', 'stnews-theme'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action('widgets_init', 'stnews_theme_widgets_init'); /** * Enqueue scripts and styles. */ function stnews_theme_scripts() { wp_enqueue_style('stnews-theme-style', get_stylesheet_uri(), array(), _S_VERSION); wp_style_add_data('stnews-theme-style', 'rtl', 'replace'); wp_enqueue_script('stnews-theme-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true); if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } } add_action('wp_enqueue_scripts', 'stnews_theme_scripts'); /** * Implement the Custom Header feature. */ require get_template_directory() . '/inc/custom-header.php'; /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Functions which enhance the theme by hooking into WordPress. */ require get_template_directory() . '/inc/template-functions.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; // nav walker require_once(get_template_directory() . '/lib/navwalker.php'); require_once(get_template_directory() . '/lib/mobile-navwalker.php'); /** * Load Jetpack compatibility file. */ if (defined('JETPACK__VERSION')) { require get_template_directory() . '/inc/jetpack.php'; } // content limit function hk_trim_content($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content) >= $limit) { array_pop($content); $content = implode(" ", $content) . '...'; } else { $content = implode(" ", $content); } $content = preg_replace('/\[.+\]/', '', $content); $content = apply_filters('the_content', $content); return $content; } add_filter('get_the_archive_title', 'replaceCategoryName'); function replaceCategoryName($title) { $title = single_cat_title('', false); return $title; } /** * Load Jetpack compatibility file. */ require get_template_directory() . '/inc/jetpack.php'; function excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt) >= $limit) { array_pop($excerpt); $excerpt = implode(" ", $excerpt) . '...'; } else { $excerpt = implode(" ", $excerpt); } $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt); return $excerpt; } function catagorydatabyid($catid_n, $limit = null, $offset = null) { // $catid_n = get_cat_ID('समाचार'); $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); $d = array(); // Initialize $d as an empty array foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", (array)$d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $loop = new WP_Query($args); return $loop; wp_reset_query(); } function parentwithchild($catid) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); foreach ($subcategories_n as $p) { $d[] = $p->slug; } } function listingnews($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); // Check if $subcategories_n is an array and not empty if (is_array($subcategories_n) && !empty($subcategories_n)) { $d = array(); // Initialize $d as an array foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
'; endwhile; endif; } else { echo 'No subcategories found.'; } } function sportsnews($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
'; endwhile; endif; } function listcatagory($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); foreach ($subcategories_n as $p) { $d = []; $a = implode(',', $d); } $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
'; endwhile; endif; } function sportscatagory($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); $d = array(); // Initialize $d as an empty array foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
'; endwhile; endif; } function listnews($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); $d = array(); // Initialize $d as an empty array foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
'; endwhile; endif; } function listnewsst($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); $d = array(); // Initialize $d as an empty array foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
'; endwhile; endif; } function listnewslist($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
'; endwhile; endif; } function listbusinesslist($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
' . get_the_post_thumbnail($loop->ID, "thumb", array('class' => 'img-fluid')) . '
' . mb_strimwidth(get_the_title(), 0, 100, '...') . '
'; endwhile; endif; } function widgetnewslist($catid_n, $limit, $offset, $colorstyle) { $subcategories_n = get_categories('&child_of=' . $catid_n . '&hide_empty'); foreach ($subcategories_n as $p) { $d[] = $p->cat_ID; } $a = implode("','", $d); $categoryid = (!empty($a)) ? $a : $catid_n; $args = array('cat' => ($categoryid), 'orderby' => 'date', 'posts_per_page' => $limit, 'order' => 'DESC', 'offset' => $offset); $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); echo $output = '
' . get_the_post_thumbnail($loop->ID, "thumb", array('class' => 'img-fluid')) . '
' . mb_strimwidth(get_the_title(), 0, 100, '...') . '
'; endwhile; endif; } function searchForCategory($array) { foreach ($array as $val) { if ($val->category_nicename != "fresh-news" && $val->category_nicename != "slider") { return $val->cat_name; } } return null; } function getallcatgorybyparentid($catid) { $subcategories_n = get_categories('&child_of=' . $catid . '&hide_empty'); //echo "
";  var_dump($subcategories_n); die();
    foreach ($subcategories_n as $p) {
        $thisCat =   get_category($p->category_parent);
        echo $output = '' . $p->name . ' ';
    }
}
function catagorydata($catagoryname, $postper)
{
    wp_reset_query();
    $args = array('cat' => $catagoryname, 'posts_per_page' => $postper, 'post_status' => 'publish', 'order' => 'DESC');
    $loop = new WP_Query($args);
    return $loop;
}
function singlecatagorydatabyid($catid, $postper)
{
    wp_reset_query();
    $args = array('cat' => $catid, 'posts_per_page' => $postper, 'post_status' => 'publish', 'order' => 'DESC');
    $loop = new WP_Query($args);
    return $loop;
}
function wpbeginner_numeric_posts_nav()
{
    if (is_singular())
        return;
    global $wp_query;
    /** Stop execution if there's only 1 page */
    if ($wp_query->max_num_pages <= 1)
        return;
    $paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1;
    $max   = intval($wp_query->max_num_pages);
    /**     Add current page to the array */
    if ($paged >= 1)
        $links[] = $paged;
    /**     Add the pages around the current page to the array */
    if ($paged >= 3) {
        $links[] = $paged - 1;
        $links[] = $paged - 2;
    }
    if (($paged + 2) <= $max) {
        $links[] = $paged + 2;
        $links[] = $paged + 1;
    }
    echo '
' . "\n"; } /*@ Get Related Posts for Single Page */ if (!function_exists('sc_get_related_posts_for_single')) { function sc_get_related_posts_for_single() { ob_start(); $id = get_the_ID(); /*@ Get current post's categories */ $categories = get_the_category($id); // Disabled this if you want tag wise posts /*@ Get current post's Tags */ // $categories = wp_get_post_tags($id); // Enable this for tags wise related posts if (!empty($categories)) : /*@ Pluck all categories Ids */ $categories_ids = array_column($categories, 'term_id'); $related_args = [ 'post_status' => 'publish', 'category__in' => $categories_ids, // Disabled this if you want tag wise posts //'tag__in' => $categories_ids, // Enable this for tag wise related posts 'post__not_in' => [$id], // Exclude Current Post 'posts_per_page' => 4, // Number of related posts to show 'ignore_sticky_posts' => 1 ]; $get_posts = new WP_Query($related_args); if ($get_posts->have_posts()) : ?>
have_posts()) : $get_posts->the_post(); ?>