this is the problem, starting at line 46:
$args = array(
'post_type' => 'post'
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post();
//stuff
endwhile;
endif;
you’re not using the original query for the page, which contains just posts from the current category, and you’re replacing it with a new query that’s loading posts of post_type
= post
, regardless of category.
to use the original query, change your loop to use the default query:
if( have_posts() ) {
while( have_posts() ) {
the_post();
//stuff
endwhile;
endif;
note the removal of $post_query->
everywhere. this loop will now use the global $wp_query
instead, which contains the posts you want to output.