HEX
Server: nginx/1.18.0
System: Linux vcwordpress 5.15.0-174-generic #184-Ubuntu SMP Fri Mar 13 18:41:50 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/stg-everycred.com/wp-content/themes/everycred/inc/ajax-handlers.php
<?php

add_action('wp_ajax_load_more_blogs', 'load_more_blogs_handler');
add_action('wp_ajax_nopriv_load_more_blogs', 'load_more_blogs_handler');

function load_more_blogs_handler()
{
    check_ajax_referer('load_more_blogs_nonce', 'nonce');

    $page     = isset($_POST['page'])     ? intval($_POST['page'])          : 2;
    $per_page = isset($_POST['per_page']) ? intval($_POST['per_page'])       : 12;
    $exclude  = isset($_POST['exclude'])  ? array_map('intval', explode(',', $_POST['exclude'])) : array();

    $query = new WP_Query(array(
        'post_type'      => 'post',
        'post_status'    => 'publish',
        'posts_per_page' => $per_page,
        'paged'          => $page,
        'order'          => 'DESC',
        'post__not_in'   => $exclude,
    ));

    if (!$query->have_posts()) {
        wp_send_json_error();
    }

    ob_start();
    while ($query->have_posts()) : $query->the_post();
        $title    = get_the_title();
        $content  = get_the_excerpt();
        $blog_img = get_the_post_thumbnail_url(get_the_ID());
        $date     = get_the_date('d M, Y', get_the_ID());
?>
        <div class="col-12 col-md-6 d-flex align-items-stretch mb-4">
            <div class="w-100">
                <div class="blog-card d-flex flex-column mt-4 h-100">
                    <a href="<?php the_permalink(); ?>" class="blog-post-img overflow-hidden position-relative">
                        <img src="<?php echo $blog_img; ?>" title="<?php echo $title; ?>" alt="<?php echo $title; ?>" width="100%" height="100%" />
                        <div class="blog-info d-flex align-items-center">
                            <div class="d-flex justify-content-between w-100 text-white">
                                <div class="font-14"><?php echo $date; ?></div>
                                <div class="font-14 text-semi">
                                    <?php
                                    $categories = get_the_category(get_the_ID());
                                    if ($categories) {
                                        foreach ($categories as $category) {
                                            echo esc_html($category->name) . ' ';
                                        }
                                    }
                                    ?>
                                </div>
                            </div>
                        </div>
                    </a>
                    <div class="font-20 text-semi text-black my-3">
                        <a href="<?php the_permalink(); ?>"><?php echo $title; ?></a>
                    </div>
                    <div class="blog-content"><?php echo $content; ?></div>
                    <div class="d-flex justify-content-between mt-auto">
                        <a href="<?php the_permalink(); ?>" class="font-16 text-medium text-blue">
                            Read post
                            <img src="<?php echo get_template_directory_uri(); ?>/assets/images/upper-right-arrow-blue.svg" alt="arrow" />
                        </a>
                        <div class="font-16 text-black">
                            <img src="<?php echo get_template_directory_uri(); ?>/assets/images/clock-black.svg" alt="clock" />
                            <?php display_reading_time(); ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php
    endwhile;
    wp_reset_postdata();

    $html = ob_get_clean();
    wp_send_json_success(array('html' => $html));
}

function case_studies_posts_per_page($query)
{
    if (!is_admin() && $query->is_main_query() && is_post_type_archive('case_studies')) {
        $query->set('posts_per_page', 12);
    }
}
add_action('pre_get_posts', 'case_studies_posts_per_page');

function load_more_case_studies()
{

    $paged = $_POST['page'];

    $args = array(
        'post_type'      => 'case_studies',
        'posts_per_page' => 12,
        'paged'          => $paged
    );

    $query = new WP_Query($args);

    if ($query->have_posts()) :
        while ($query->have_posts()) : $query->the_post(); ?>

            <div class="col-12 col-md-6 col-lg-4 mb-4">
                <a href="<?php the_permalink(); ?>">
                    <div class="list-box h-100">
                        <div class="image-box">
                            <img class="w-100"
                                src="<?php echo get_the_post_thumbnail_url(get_the_ID(), 'large'); ?>"
                                alt="<?php the_title(); ?>" />
                        </div>
                        <div class="desc-box bg-white p-3">
                            <div class="title-txt font-18">
                                Case Study | <?php echo get_the_date('d M Y'); ?>
                            </div>
                            <div class="desc-txt font-20 text-semi font-light-black mt-2">
                                <?php the_title(); ?>
                            </div>
                        </div>
                    </div>
                </a>
            </div>

        <?php endwhile;
    endif;

    wp_die();
}

add_action('wp_ajax_load_more_case_studies', 'load_more_case_studies');
add_action('wp_ajax_nopriv_load_more_case_studies', 'load_more_case_studies');