AJAX Breaking Offset Argument In WP Query

So I’m guessing this is a follow-up to this question. And based on my answer there, you can use/add the offset parameter like so:

  1. In category.php, just set the preferred offset:

    $the_query = new WP_Query( array(
        'category__in'   => array( $cat_id ),
        'post_type'      => 'post',
        'posts_per_page' => 5,
        'paged'          => $current_page,
        'offset'         => 1, // set offset
    ) );
    
  2. In misha_loadmore_ajax_handler() (the PHP function which processes the AJAX requests), add this right before $the_query = new WP_Query( $args );:

    if ( isset( $args['offset'] ) ) {
        $offset = absint( $args['offset'] );
        $args['offset'] = absint( ( $args['paged'] - 1 ) * $args['posts_per_page'] ) + $offset;
    }
    

That’s all. No changes necessary in the JavaScript parts.