0

I'm new to WP theme development and I've an issue.

I've created a custom post type 'portfolio' via CPT UI plug-in. Now I want to create a custom query to show all the posts with the post_type = 'portfolio'. Here is my code

<div class="row">

    <?php
        $args = array (
            'post-type' => 'portfolio'
        );
        $the_query = new WP_Query( $args );
    ?>

    <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>


    <div class="col-sm-3 portfolio-piece">

        <h3><?php the_title(); ?></h3>

    </div>

    <?php endwhile; endif; ?>

</div>

Somehow it shows me the only one post 'Hello World!' with the post_type = 'post'. By the way, I don't even have this post.

Thank you!

1

You have 'post-type' in code instead of 'post_type'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.