[wp-testers] SOLVED: Re: is this an error in codex, 3.0 beta, or my coding error?
Danny G Smith
dgs at riskiii.com
Sun May 23 19:02:41 UTC 2010
You are absolutely right. I will try to find out how to edit the codex, and change it there so other people don't have the same issue.
Danny G Smith
dgs at riskiii.com
On May 23, 2010, at 1:56 PM, Matt Martz wrote:
> On Sun, May 23, 2010 at 1:20 PM, Danny G Smith <dgs at riskiii.com> wrote:
>> More information:
>>
>> I have now tried this with a clean install from svn trunk, and putting it in twenty-ten funtions.php, and still get the error. I tried it in the 2.9.* branch and get an error there as well. Like I say, it came from the codex, almost verbatim, so I don't think it is something I did, unless I need to include something that I don't know about.
>>
>>
>>> This is not verbatim, from the codex, page http://codex.wordpress.org/Template_Tags/wp_list_pages but very close to what I added to the functions.php file:
>>>
>>>
>>> $parent = 19;
>>> $myArgs=array(
>>> 'child_of' => $parent
>>> );
>>> $pages = get_pages($myArgs);
>>> if ($pages) {
>>> $pageids = array();
>>> foreach ($pages as $page) {
>>> $pageids[] = $page->ID;
>>> }
>>> }
>>>
>>> echo "<pre>";
>>> print_r ($pageids);
>>> echo "</pre>";
>>>
>>> It prints out the array ok, but I get the following error.
>>>
>>> Catchable fatal error: Object of class stdClass could not be converted to string in /var/www/mockup/htdocs/wp-includes/classes.php on line 277
>
> The problem is with this line:
>
>>> foreach ($pages as $page) {
>
> What is happening is that you are overwriting the global $page var
> with an object with what should be a string.
>
> Change $page to something like $mypage and you will be good. There
> are numerous global vars from the global scope that can be overwritten
> which will cause such issues. Also stay away from $post, $p, etc...
>
> --
> Matt Martz
> matt at sivel.net
> http://sivel.net/
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
More information about the wp-testers
mailing list