Forked from gianlucacandiotti/WP - get custom post
Created
December 20, 2018 23:02
-
-
Save pavlo-bondarchuk/4479b89255520f94423f8db0daa4899e to your computer and use it in GitHub Desktop.
Get all posts for a custom post type and query them.
This file contains hidden or 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