Illeagal string offset
-
Hey guys so on my front page i have a repeatable group field were i add all the services that my client provides.it works great and i even add a counter to break it up into three list. But then i need to add a portfolio section and i built my own custom post type for this as a plugin so that i could try and build out all the functionality myself and basically make my own plugin but when i try and add the post via a shortcode or directly to the page it breaks the code some how and i get this error which his associated with the cmb2 out put array for the services provided
warning: Illegal string offset ‘service’ in /var/www/vhosts/avidbeta.com/httpdocs/wp-content/themes/wpBootStrap/front-page.php on line 75
Notice: Uninitialized string offset: 0 in /var/www/vhosts/avidbeta.com/httpdocs/wp-content/themes/wpBootStrap/front-page.php on line 75
but then when i remove that my shortcode the error goes away.
So i guessmy question is is it my custom post type code that is breaking everything or do i jsut not have the array set up correctly for the cmb2 fields…here is that code
<?php $services = get_post_meta( get_the_ID(), '_services_section_content', true ); $counter = 1; foreach ( (array) $services as $key => $service ) { if (isset($service['service'])) $serviceProvided = ''; $serviceProvided = esc_html( $service['service'] ); if( $counter%5 == 1){echo '<ul>';}?> <li><?php echo $serviceProvided ?> </li> <?php if( $counter%5 == 0){echo '</ul>';} $counter++; } if ($counter%5 != 1) echo '</ul>'; ?>I am at a loss on how to fix the array if that is what it is.
Thanks
The topic ‘Illeagal string offset’ is closed to new replies.