Unstoppable Domains

Error in line <? foreach($postimg as $image)

Spaceship Spaceship
Watch

sbs

Established Member
Impact
3
Hi,I am new to programming.

If you look at the following blog http://outdooractivitiesforkids.com/wordpress/?p=3 I get the following error

Warning: Invalid argument supplied for foreach() in /home/a6228915/public_html/wordpress/wp-content/themes/positie_1/index.php on line 11

and LINE 11 in index.php says

1. <?php get_header(); ?>
2.
3. <?php include(TEMPLATEPATH."/sidebar.php");?>
4.
5. <!-- begin content -->
6. <div id="main">
7. <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
8. <h1><?php the_title(); ?></h1>
9.
10. <? $postimg = get_post_meta($post->ID, "pre_image", false); ?>
11. <? foreach($postimg as $image) {
12. echo "<img class=\"fullimg\" src=\"".$image."\" />";
13. } ?>
.
.
.
.
.

Please help. I am new to programming.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
it is basically telling you that $postimg is not an array so you can't use it in a foreach.

double check get_post_meta is meant to be returning an array. Also try doing print_r($postimg) and you will see what $postimg contains
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back