I’m having problems with the syntax for a php array.
<?php
$pages = get_pages(array('child_of' => $post->ID, 'sort_column' => 'menu_order'));
$data = array();
foreach($pages as $post){
setup_postdata($post);
$fields = get_fields();
$data[] = '<p>'.$fields->company_name.'</p><img src="'.$fields->company_logo."' />';
}
wp_reset_query();
// the js array
echo 'var marker_data = ' . json_encode($data) . ';'; // Instead of implode
?>
Specifically this line:
$data[] = '<p>'.$fields->company_name.'</p><img src="'.$fields->company_logo."' />';
I’m getting all kinds of errors with adding the img tag, how would I format it correctly?
You just changed the
'"to"'which was wrong 🙂