Last active
November 2, 2019 12:56
-
-
Save gianlucacandiotti/24f08154ec019a76b13a to your computer and use it in GitHub Desktop.
Get all posts for a custom post type and query them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$type = 'custom_post_type'; | |
$args = array( | |
'post_type' => $type, | |
'post_status' => 'publish', | |
'posts_per_page' => -1, | |
'ignore_sticky_posts'=> true | |
); | |
$my_query = null; | |
$my_query = new WP_Query($args); | |
?> | |
<?php if( $my_query->have_posts() ):?> | |
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?> | |
<?php endwhile; ?> | |
<?php | |
endif; | |
wp_reset_query(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment