Retrieve custom post types with a category


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php $posts = new WP_Query(array(
  2. 'post_type' => 'here_goes_my_post_type',
  3. 'category' => 'Here Goes My Category',
  4. )); ?>
  5. <?php while ( $posts->have_posts() ) : $posts->the_post(); ?>
  6. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  7. <h2><?php the_title(); ?></h2>
  8. <?php the_content(); ?>
  9. </div>
  10. <?php endwhile; ?>
  11. <?php wp_reset_query(); ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.