Support » Plugins » Custom post type not showing in WP_Query loop

  • I’m using the Custom post types UI plugin and have written a loop to iterate through these posts. I can’t get my posts to show up even though I have confirmed they exist. I’m not entirely sure what’s missing here and any help would be much appreciated.

    Here is my code:

    <?php 
    
                $args = array(
                    'post_type' => 'portfolio'
                );
                $the_query = new WP_Query($args);
    
            ?>
    
            <?php if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
    
            <div class="col-sm-3 portfolio-piece">
    
                <p><?php the_post_thumbnail('medium'); ?></p>
                <h3><?php the_title(); ?></h3>
    
            </div>
    
            <?php endwhile; endif; ?>
            <?php wp_reset_query(); ?>
  • The topic ‘Custom post type not showing in WP_Query loop’ is closed to new replies.