Skip to content

Instantly share code, notes, and snippets.

@isaacdanielanderson
Last active October 10, 2018 20:20
Show Gist options
  • Save isaacdanielanderson/fb97f1bcca4ddbd0ecccf167f98a74ea to your computer and use it in GitHub Desktop.
Save isaacdanielanderson/fb97f1bcca4ddbd0ecccf167f98a74ea to your computer and use it in GitHub Desktop.
Query in specific custom post type with a custom query
<?php
$servicesCpt = new WP_Query(array(
'posts_per_page' => -1,
'post_type' => 'teamMembers',
'orderby' => 'title',
'order' => 'DESC'
)
);
if ($servicesCpt->have_posts()) { ?>
<?php
while($servicesCpt->have_posts()) {
$servicesCpt->the_post(); ?>
<!-- content here -->
<?php } // end while ?>
<?php
} // end if
wp_reset_postdata(); // reset after query
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment