{
Leyland}
So, as a starter to my new series of posts, all for handy little copy and paste code snippets, I thought I’d start with an easy one: How to get custom post type by ID.
It’s a simple as:
<?php $the_query = new WP_Query( ‘post_type=custom_post_type&p=1‘ ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<?php the_content () ?>
<?php endwhile; ?>
To get custom post type by ID, make sure to edit the “1” under p= to your ID and make sure you change “custom_post_type” to your custom post type name.
Are you having trouble? If so, make sure you check out the Codex by WordPress: https://codex.wordpress.org/Class_Reference/WP_Query or, comment on this post and I’ll see if I can help!
Don’t forget to share or reference this in the forums if you come across the same issue.