WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] wp_list_pages() child_of not working

[Resolved] wp_list_pages() child_of not working

  • Hi, I was wondering if someone could help me get the following code working. Basically, I’m using the wp_list_pages() array code to get the parameters of ‘child_of’ ID. (I’m using this code because I’d like to list the pages without the use of list tags <li></li>). So far it’s worked fine expect when I try to display the child pages of a parent page it doesn’t seem to pick up the ID correctly. Here’s the code:

    $args = array(
    'post_type'   => 'page',
    'child_of'    => 2, // Problem Here
    'echo'        => 1,
    'sort_column' => 'menu_order',
    'depth'       => 0,
    );              
    
    $pages = get_posts($args);
      foreach($pages as $page) {
    	  $out .= '';
    	  $out .=  '<a href="'.get_permalink($page->ID).'" title="'.wptexturize($page->post_title).'">'.wptexturize($page->post_title).'</a>';
      }
    $out = '' . $out . '';
    echo $out;
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] wp_list_pages() child_of not working’ is closed to new replies.