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.Please have a look .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 .Please help me its very very urgent. I need to fix this immediately.

Thanks

<?php  
$loop = new WP_Query( array( 'post_type' => 'page','ID'=> 30) );
while ( $loop->have_posts() ) : $loop->the_post();
  the_content();
endwhile;
?>  

Answers


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)?


Need Your Help

PL/SQL Cursor for loop

oracle plsql for-loop cursor

I believe I need a cursor for loop to go through the street1 column from table test_data. I have a program which needs to test each row from the table.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.