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>

Leave a Reply

Your email address will not be published. Required fields are marked *