WordPress页面如何显示所有页面内容

3
我已经在当前页面显示了所有页面内容,但是不想显示当前页面的内容,下面的代码给我所有页面内容,但是如何过滤它呢?
谢谢。
 $pages = get_pages(); 
 foreach ($pages as $page_data) {
     $content = apply_filters('the_content', $page_data->post_content); 
  $title = $page_data->post_title; 
 echo $content; 
}

1
使用特定父页面:'global $post; wp_list_pages(array('child_of'=>$post->post_parent,'depth' => 2,'exclude' => get_the_ID()));' - Ravi
1个回答

2
尝试使用以下代码:通过获取当前页面的ID,它将排除当前页面。
<?php                                   
    $args = array(
        'post_type' => 'page',
        'numberposts' => -1,                                                                    
        'sort_order' => 'ASC',
        'sort_column' => 'post_title',
        'post_status' => 'publish',                 
        'exclude' => get_the_ID()
    );          
//$allpages = get_pages($args );  ?>
<?php wp_list_pages( $args ); ?> 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接