Skip Navigation

[Resolved] Object of class stdClass could not be converted to string

This thread is resolved. Here is a description of the problem and solution.

Problem:
Custom field display following error on front-end

Catchable fatal error: Object of class stdClass could not be converted to string in /home/../wp-content/plugins/types/library/toolset/types/embedded/frontend.php on line 638

Solution:
This is a logical coding error. See solution here:
https://stackoverflow.com/a/9094319

More:
https://www.google.com.pk/search?q=Catchable+fatal+error%3A+Object+of+class+stdClass+could+not+be+converted+to+string+in&oq=Catchable+fatal+error%3A+Object+of+class+stdClass+could+not+be+converted+to+string+in&aqs=chrome..69i57.19561j0j7&sourceid=chrome&ie=UTF-8

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by romanB-3 7 years, 3 months ago.

Assisted by: Noman.

Author
Posts
#559865

Hello,

I have set a custom field called "numero", which should be the unique incremented ID of the custom post type "bon-de-commande".

For this, I have created this function, which populates the field "numero" when a new "bon-de-commande" is created :

		$nb_bc = wp_count_posts('bon-de-commande');
		update_post_meta($post_id, 'wpcf-numero', ($nb_bc->publish + 1));

But when I try to display the field value on front end, I got this message Catchable fatal error: Object of class stdClass could not be converted to string in /home/../wp-content/plugins/types/library/toolset/types/embedded/frontend.php on line 638

Thank you.

#559903

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Roman,

Thank you for contacting Toolset support. This looks like a logical coding error. See solution here:
https://stackoverflow.com/a/9094319

More:
hidden link..69i57.19561j0j7&sourceid=chrome&ie=UTF-8

Thanks

#559906

So I did this : store the number as a string.
This seems odd but it works.
Thank you.