WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
[resolved] Error using Post Object on V 4.0.3 (4 posts)

  1. bagwis
    Member
    Posted 1 year ago #

    Hello,

    This is the first time I use this plugin and I admit this is really great, but unfortunately, I got an error when I am trying to echo the value of a post object. What I am want to do is first try to echo the value set in my Post Object, but I got this error message Post Object Custom Field:
    Catchable fatal error: Object of class WP_Post could not be converted to string in C:\xampp\htdocs\wordpress\wp-content\plugins\advanced-custom-fields\core\api.php on line 389. I followed the sample code in the website and since I only have one value for every post object I modified the code and made it like this

    $post_objects = get_field('field_51709d17971fb');

    if( $post_objects ): ?>

    <?php foreach( $post_objects as $post_object): ?>

    <span>Post Object Custom Field: <?php the_field('order_equipment_name', $post_object->ID); ?></span>

    <?php endforeach; ?>

    <?php endif;

    Now my original plan is to update the quantity value in my product post type by subtracting the quantity in the order post type, to achieve this, I have to provide the specific postid of the said product in the post object.

    I downloaded the last 3.5.8 version and will try if this will work out for me. I hope that it would cause I badly need this one. Thanks

    Kind Regards

    http://wordpress.org/extend/plugins/advanced-custom-fields/

    UPDATE:
    I tried the version 3.5.8 but still I got the same error and also the custom fields that I created are still missing when I go to the custom fields, I can clearly see that there are 4 published custom fields but they aren't showing. I don't have other plugins installed aside from this and custom post type UI, I used to manually code the custom post type but I tried to use the plugin thinking that it might be the reason that my custom fields disappeared. But the same issue occurs. Thanks

  2. bagwis
    Member
    Posted 1 year ago #

    Never mind the code, I was able to manage it, I realized that to echo the product name, it should be the, <?php the_title(); ?>.

    Anyway, what I need now is the answer for my other question, why does my custom fields aren't showing on my field groups?

    Thanks

  3. bagwis
    Member
    Posted 1 year ago #

    Sorry to bump this one again, I couldn't find anymore the edit link. I can't achieve my goal using the code above, is there a way that I can immediately echo the value of a post object similar to the other custom types wherein entering the code the_field('$field_key') will just echo the value of that field? I've been searching for more almos 24 hours now but I couldn't find any idea. Thanks

  4. bagwis
    Member
    Posted 1 year ago #

    Never mind, I resorted to manually code it myself. Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.