Fetching the particular post having post type page
I'm facing some problem when I fetch page content of particular Id. I'm using the code given below.
There is many pages in my database, I just want to show the page having id =30
and post_type=page
. When I'm using the code given below it show all page content having post_type=page
. But I just only the one. I think there is some syntax problem in my code.
<?php
$loop = new WP_Query( array( 'post_type' => 'page','ID'=> 30) )开发者_开发百科;
while ( $loop->have_posts() ) : $loop->the_post();
the_content();
endwhile;
?>
Try this
global $wpdb;
$details = $wpdb->get_var("SELECT * FROM $wpdb->posts WHERE ID=30 and post_type='page'");
return $details;
or
<?php
$args=array(
'post_type'=>'page',
'post__in' => array('595', '33', 44)
);
$the_query = new WP_Query($args);
?>
Good luck
Errm, what happened to good old get_post(30)
?
精彩评论