PHP issue showing the word array on home page
-
<div class="homeheading"><h3><?php if (ICL_LANGUAGE_CODE == 'en') { echo "NOW BOOKING..."; } else { echo "NAWR ARCHEBU..."; }?></h3></div> <?php if (ICL_LANGUAGE_CODE == 'en') { echo $posts = get_field('home_events'); if ($posts): ?> <?php foreach ($posts as $p): // variable must NOT be called $post (IMPORTANT) ?> <div class="block-e"> <?php if (has_post_thumbnail($p->ID, 'feature')) { ?> <?php echo get_the_post_thumbnail($p->ID, 'feature'); ?> <?php } else { ?> <img class="attachment-feature wp-post-image" src="/wp-content/themes/CMF/images/CMF-block.jpg" alt="cowbridge music festival"/> <?php } ?> <div class="block-e-title"><h2><a href="<?php echo get_permalink($p->ID); ?>"><?php echo get_the_title($p->ID); ?></a></h2></div> <div class="e-date"><?php add_filter('the_content', 'do_shortcode', 11); echo do_shortcode('[event post_id="' . $p->ID . '"]#_EVENTDATES, #_EVENTTIMES<br />[/event]'); ?></div> <div class="more-e"><a href="<?php echo get_permalink($p->ID); ?>">More ></a></div> </div><!-- .block-e --> <?php endforeach; endif; } else { echo $posts = get_field('home_events'); if ($posts): ?> <?php foreach ($posts as $p): // variable must NOT be called $post (IMPORTANT) ?> <div class="block-e"> <?php if (has_post_thumbnail($p->ID, 'feature')) { ?> <?php echo get_the_post_thumbnail($p->ID, 'feature'); ?> <?php } else { ?> <img class="attachment-feature wp-post-image" src="/wp-content/themes/CMF/images/CMF-blockw.jpg" alt="cowbridge music festival"/> <?php } ?> <div class="block-e-title"><h2><a href="<?php echo get_permalink($p->ID); ?>"><?php echo get_the_title($p->ID); ?></a></h2> <div class="e-date"><?php add_filter('the_content', 'do_shortcode', 11); echo do_shortcode('[event post_id="' . $p->ID . '"]#_EVENTDATES, #_EVENTTIMES<br />[/event]'); ?></div> <div class="more-e"><a href="<?php echo get_permalink($p->ID); ?>">More ></a></div> </div> </div><!-- .block-e --> <?php endforeach; endif; }?>
The above code is for a block on my home page which uses Advanced Custom Fields to display chosen events on the home page. It all works perfectly and changes when the user switches to the Welsh version.
The problem I have, is the word array is appearing on the page above the last event.
I think it is my php but I can’t find the problem, any help would be much appreciated!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘PHP issue showing the word array on home page’ is closed to new replies.