wp_query post id code example
Example 1: wp query
<?php
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Example 2: wordpress query a post by id
//WordPress: Query a specific post by its post type & ID
//For example, query Case Study with ID #12345
<?php query_posts('post_type=case_studies&p=12345'); ?>
/*To determine a post ID, refer to the
URL of the post while editing it:
http://localhost...wp-admin/post.php?post=12345...*/