Ajax Load More Posts in Category Page

Your query parameters don’t contain any category arguments. You need to pass and set cat or category_name along with the post type, offset, and posts per page. You can get the current category’s ID via get_queried_object():

$queried_object = get_queried_object();  
$cat_id = $queried_object->term_id;

Output and retrieve the value somewhere in your category template, or better, when you enqueue your ajax javascript, check if is_category and use wp_localize_script() to pass that data to your script.

Leave a Comment