Reputation:
I want to show the title of the page with no links to the draft pages.
this is my code
<?php
wp_list_pages( array(
'title_li' => '',
'child_of' => '4721',
'post_status' => 'publish,draft'
) );
?>
Upvotes: 0
Views: 58
Reputation: 837
You can do this with WP_Query object :
$child_pages_query = new WP_Query(array(
'post_type' => 'page',
'posts_per_page' => '-1',
//'post_parent' => '4721',
'post_status' => array('publish', 'draft')
));
if($child_pages_query->have_posts()){
while($child_pages_query->have_posts()){
$child_pages_query->the_post();
if('publish'==get_post_status(get_the_ID())){
echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
}else{
echo '<li>'.get_the_title().'</li>';
}
}
wp_reset_postdata();
}
Upvotes: 0