How reterive page/post/category detail ?


Use this code for reterive page detail.

<ul id=”red”>

<?php
global $wpdb;
$curent_id =$post->ID;
$myPages = $wpdb->get_col(“SELECT ID,guid FROM $wpdb->posts WHERE post_parent =’$curent_id’ AND post_status=’publish’ AND post_type=’page'”);

foreach($myPages as $myPagess )
{
$numberPages = $wpdb->get_var(“SELECT count(*) FROM $wpdb->posts WHERE post_parent =’$myPagess’ AND post_status=’publish’ AND post_type=’page'”);
if($numberPages==0)
{
echo “<li><span><a href='”.get_permalink($myPagess).”‘>”.get_the_title($myPagess).”</a></span></li>”;

}
else
{
//echo “SELECT ID,guid FROM $wpdb->posts WHERE post_parent =’$curent_id’ AND post_status=’publish’ AND post_type=’page'”;
$ChieldPage = $wpdb->get_col(“SELECT ID FROM $wpdb->posts WHERE post_parent =’$myPagess’ AND post_status=’publish’ AND post_type=’page'”);
//print_r($ChieldPage);
echo “<li><span><a href='”.get_permalink($myPagess).”‘>”.get_the_title($myPagess).”</span></a>”;
foreach($ChieldPage as $mysubPagess )
{

echo “<ul><li><span><a href='”.get_permalink($mysubPagess).”‘>”.get_the_title($mysubPagess).”</a></span></li></ul>”;
}
echo “</li>”;
}
}

?>

</ul>

Advertisements

Sr. Software Engineer

Posted in PHP, Wordpress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: