Hello everyone,
please help me with the error I get (similar to other posters’).
I pasted mintimperial‘s code into my page.php, right after the beginning of posts loop:
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php $images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . $post->ID );
$firstImageSrc = wp_get_attachment_image_src(array_shift(array_keys($images)));
echo "<img src=\"{$firstImageSrc[0]}\" width=\"32\" height=\"32\" />"; ?>
I get 2 errors:
Warning: array_keys(): The first argument should be an array in /home/www/mywebsite.com/wp-content/themes/basic2col/page.php on line 11
Warning: array_shift(): The argument should be an array in /home/www/mywebsite.com/wp-content/themes/basic2col/page.php on line 11
Line 11 being
$firstImageSrc = wp_get_attachment_image_src(array_shift(array_keys($images)));
Is this because $images is actually empty?
And then is &images empty because it searches for pics in posts on the current page (and current page is empty, has no posts)?
If correct, then how do I make it search through all posts in the blog, not only on the current page?
Thanks for support.