0

Here's my code:

        $args = array(
            'child_of' => $CurrentPage
            );
        $children = get_pages( $args );
        foreach ($children as $child) {
            foreach ($child as $key => $value) {
            echo $key['post_title'];
            }
        };

And output:

IpppppppcppptpppppgmppcfIpppppppcppptpppppgmppcf

The output appears to be the first character of the $key, repeated over both children.

ID , post_author , post_date , post_date_gmt , post_content , post_title , etc.

0

You're doing one to many loops. What you want to be doing is this:

$args = array(
    'child_of' => $CurrentPage
);
$children = get_pages( $args );
foreach ($children as $key => $value) {
    echo $key['post_title'];
};

Or you could also:

$args = array(
    'child_of' => $CurrentPage
);
$children = get_pages( $args );
foreach ($children as $child) {
    echo $child->post_title;
};

It's entirely up to you, but since you already know what elements each $child has, why not stick to the same syntax as used in the get_pages() Codex article?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.