Custom Post type category pages template and loop

I have a custom post type by the name of the event.

So Created a category page them for them like this →

category-event.php

Like this →

<?php get_header(); ?>
//and then the loop here
<?php get_footer(); ?>

But the individual category pages are not generating the posts only from those categories, but entirely all posts.

I think something needs to be fixed in the loop?

Update → the Loop

$the_query = new WP_Query( array(
‘post_type’ => ‘event’,
‘posts_per_page’ => 10,
‘post_status’ => ‘publish’,
) );
?>
<?php if ( $the_query->have_posts() ) : ?>
<!– the loop –>
<div class=”class1″>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class=”class2″>
<div class=”class3″>
<?php $url = esc_url( get_post_meta( get_the_ID(), ‘video_oembed’, true ) ); ?>
<?php $embed = wp_oembed_get( $url ); ?>
<div class=”class4″>
<iframe id=”class_frame” width=”560″ height=”315″ src=”https://www.youtube.com/watch”); ?>” allowfullscreen frameborder=”0″></iframe>
</div>
</div>
<div class=”class6″>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div>
<!– end of the loop –>
<!– <?php wp_reset_postdata(); ?> –>
<?php endif; ?>

Read more here:: Custom Post type category pages template and loop

Leave a Reply

Your email address will not be published. Required fields are marked *