Support

Account

Home Forums Add-ons Repeater Field Error: Cannot use object of type WP_Post as array

Solving

Error: Cannot use object of type WP_Post as array

  • Hello,

    looking at the error_log file in my VPS I have noticed that a lot of errors are related to ACF:
    PHP Fatal error: Cannot use object of type WP_Post as array in /home/domainname/public_html/wp-content/plugins/advanced-custom-fields/core/api.php on line 577

    Recently I have created a new field calle “Punti vendita” (Repeater) and 4 related subfields a in parallel I have modified a wordpress template (single articled) in order to read these new values.

    I suspect that something in the code I have added can create this issue.
    Could you please check and let me know ?

    
    <?php 
    
    if(get_field('punti_vendita')): ?>
    
    <table id="punti-vendita" width="600" border="0" cellspacing="0" cellpadding="0">
      
    <?php while(has_sub_field('punti_vendita')): ?>
     <tr>
        <td>
    	<li><?php the_sub_field('indirizzo_punto_vendita'); ?></li></td>
        <td><?php the_sub_field('giorno_della_settimana'); ?>, <?php the_sub_field('orario'); ?></td>
      </tr>
      <tr>
        <td colspan="2">Servizi: <?php the_sub_field('servizi'); ?></td>
      </tr>
     <tr>
        <td colspan="2" style="background-color:#EEE;height:3px;padding:0;line-hight:1px"> </td>
      </tr>
    	
     
    	<?php endwhile; ?>
     
    </table>
     
    <?php endif; ?>
    
  • Hi @tecnologo

    What version of ACF are you using? The line you referenced does not contain any code in the current 4.3.2 version.

    The issue may be that you are using the_sub_field function to echo an object. Is this possible? Are any of the sub fields returning an object?

    Thanks
    E

  • Hi,

    the ACF version I am using is Advanced Custom Fields 4.1.6 on WordPress 3.5.

    I do not understand whe you say “Are any of the sub fields returning an object?”. What I can see is that I have a repeater and 4 subfields that are “text” type.

    Is there a way to check if they return object?
    Please let me know.
    Thanks
    Salvo

  • Hi @tecnologo

    If all 4 sub fields are text, then they will not be returning an object. Field types such as image, post object do.

    Perhaps you could update your version of ACF to fix the issue? It is hard for me to debug and help solve an issue when the issue is occurring on an older version of ACF.

    If you do not wish to update to ACF 4.2, perhaps you could update to 4.1.8? You can download all version on the WP website here:
    http://wordpress.org/plugins/advanced-custom-fields/developers/

    If you can, please update to ACF 4.3.2

    Thanks
    E

  • Hi,
    thanks for your reply.

    As you suggested I would like to update the ACF to the last version 4.3.3 but looking at the plugin page in WP it doesn’t show the “update now” link as in the other plugins.

    So I do you suggest to proceed for the update? Delete the old version and upload the new one?

    The same question is for the “Repeater Field” plugin I have bought, what’s the best approach for the update.

    ACF is widely used in my website and I don’t want to have any problems or impact with the post and the pages currently online.

    Thanks for your support
    Salvo

  • Hi @tecnologo

    The repeater field will continue to work, but please also update this to the latest version.

    You can delete and replace the advanced-custom-fields folder in the wp-plugins area to update.

    Thanks
    E

  • Hi @tecnologo

    If you are worried about upgrad issues. Please move the old acf plugin to a temp folder in case you need to put it back. This is a simple backup technique that can save you lots of time if anything goes wrong.

    Perhaps also create a DB backup too

    Thanks
    E

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

The topic ‘Error: Cannot use object of type WP_Post as array’ is closed to new replies.