• I am getting this error:
    Catchable fatal error: Object of class WP_Post could not be converted to string in /home/public_html/wp-content/themes/Avada-Child-Theme/woocommerce/single-product.php on line 103.
    I am using the relationship field type and using this in my template file:

    <?php
    
    $values = get_field('field_name');
    if($values)
    {
    	echo '<ul>';
    
    	foreach($values as $value)
    	{
    		echo '<li>' . $value . '</li>';
    	}
    
    	echo '</ul>';
    }
    
    // always good to see exactly what you are working with
    var_dump($values);
    
    ?>
    

    I did a var_dump and this is what I got:
    array(1) { [0]=> object(WP_Post)#2711 (24) { [“ID”]=> int(10120) [“post_author”]=> string(1) “6” [“post_date”]=> string(19) “2013-06-06 13:34:05” [“post_date_gmt”]=> string(19) “2013-06-06 17:34:05” [“post_content”]=> string(937) ”
    Blend ingredients in the given sequence while stirring. Adjust the pH value with sodium hydroxide to pH appox. 2.5.” [“post_title”]=> string(46) “”Easier Next Time” Bathroom Cleaning” [“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish” [“comment_status”]=> string(6) “closed” [“ping_status”]=> string(4) “open” [“post_password”]=> string(0) “” [“post_name”]=> string(43) “bathroom-cleanser-easier-next-time-cleaning” [“to_ping”]=> string(0) “” [“pinged”]=> string(0) “” [“post_modified”]=> string(19) “2016-10-25 12:21:43” [“post_modified_gmt”]=> string(19) “2016-10-25 16:21:43” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(67) “http://test.com/?post_type=formulations&p=2219&#8221; [“menu_order”]=> int(0) [“post_type”]=> string(12) “formulations” [“post_mime_type”]=> string(0) “” [“comment_count”]=> string(1) “0” [“filter”]=> string(3) “raw” } }

    Help appreciated.

The topic ‘Catchable fatal error’ is closed to new replies.