Support

Account

Home Forums Front-end Issues update_field() for comment fields

Solving

update_field() for comment fields

  • There doesn’t seem to be an equivalent to the update_field() function for comment fields. Attempting to update comment fields with that function inserts rows into the postmeta table rather than commentmeta. Is there a workaround for this?

  • Hi @zanetaylor
    I also needed to update the custom fields associated with a comment and I discovered that the function update_field () can be used, as in other cases. In the case of comments, however, it is necessary to pass the object and not the ID, as in this example.

    
    <?php
    
    update_field( 'field_5a46bb8740511', $value, get_comment($comment_id) ); 
    
    ?>
    
    • futaba

    • June 26, 2020 at 6:50 pm

    Excellent! Thank you very much. 👏

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.