Support

Account

Home Forums Front-end Issues Unable to retrieve simple values

Helping

Unable to retrieve simple values

  • I am working on a multi-site wordpress environment until the first three sites custom fields values were retrieving nicely, as soon as we started working on fourth website, get_field method is not retrieving values.
    All fields are text fields, they are not global to all sites, every site has their own ACF plugin and own set of fields.

    the code I am using is very simple right now I am trying to pull the value on console.

    console.log('<?=get_field('cm_page_id')?>');
    console.log('<?=get_field('cm_page_id',$post->ID)?>');
    console.log('<?=$post->ID?>');

    the output of the code is:
    first two lines are empty
    last line has post id

  • Hi @zulfiqar.a.memon

    FYI: You can debug PHP code like so without needing to use JS:

    
    <?php 
    
    echo '<pre>';
    	print_r( get_field('cm_page_id') );
    echo '</pre>';
    die;
    
     ?>
    

    What does the PHP print_r give you? Perhaps the returned value is an array or object?

    Thanks
    E

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

The topic ‘Unable to retrieve simple values’ is closed to new replies.