Title: Invalid argument &#8211; template-functions-post.php
Last modified: August 18, 2016

---

# Invalid argument – template-functions-post.php

 *  [itiswarm](https://wordpress.org/support/users/itiswarm/)
 * (@itiswarm)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/invalid-argument-template-functions-postphp/)
 * Hi all, I can’t seem to resolve a particular error message I’m getting on a Links
   page I created (see example at [http://www.onkels.org/?page_id=18](http://www.onkels.org/?page_id=18)).
 * The error coming up is:
 * Warning: Invalid argument supplied for foreach() in
    /homepages/18/d91693023/
   htdocs/onkels/wordpress/wp-includes/template-functions-post.php on line 378
 * Line 378-385 reads:
 * foreach($page_tree[$parent][‘children’] as $page_id) {
    $cur_page = $page_tree[
   $page_id]; $title = $cur_page[‘title’];
 * $css_class = ‘page_item’;
    if( $page_id == $queried_obj->ID) { $css_class .= ‘
   current_page_item’;
 * }
 * For reference, this is a custom page template that I created and the error only
   shows up on that page. I’m running WP 1.5.2 and the Regulus theme.
 * The code in my sidebar directly before the error is:
 * <?php
 *  // —————
    // add child pages // ————— if ( is_page() ) { global $bm_pageID; 
   $bm_pages = wp_list_pages( ‘sort_column=menu_order&depth=1&title_li=&echo=0&child_of
   =’ . $bm_pageID );
 *  if ( $bm_pages <> “” ) {
    echo “<ul id=\”subpages\”>\n”; echo ”
    - <h2>Sub Pages</h2>
    - “;
       echo $bm_pages; echo “”; } }
    - Many thanks,
       Dave

Viewing 1 replies (of 1 total)

 *  [jwurster](https://wordpress.org/support/users/jwurster/)
 * (@jwurster)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/invalid-argument-template-functions-postphp/#post-295008)
 * I think I saw this error elsewhere (please do a search) and the solution was 
   to add “(array)” at the beginning of the argument. In your case it would look
   like “(array)$page_tree”.

Viewing 1 replies (of 1 total)

The topic ‘Invalid argument – template-functions-post.php’ is closed to new replies.

## Tags

 * [invalid](https://wordpress.org/support/topic-tag/invalid/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [jwurster](https://wordpress.org/support/users/jwurster/)
 * Last activity: [20 years, 6 months ago](https://wordpress.org/support/topic/invalid-argument-template-functions-postphp/#post-295008)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
