Support

Account

Forum Replies Created

  • Hi, i’ve just posted an answer about it, please, check if it can help you:

    https://support.advancedcustomfields.com/forums/topic/acf-json-not-updating/#post-54584

    I’ve changed the get_stylesheet_diretory() to get_template_directory(), that way i need to update only my parent theme and the child themes inherit.

    Don’t need to use the config load and save on each site, only in the main-parent-theme.

  • Hi, i’ve found something, but i don’t know if is your case.

    I’m using acf-pro on a mulsite enviroment and i’ve found and issue when using child themes.

    Scenario: i want to create and modify my custom fields on my parent theme, localhost, and show on wp-admin for users but don’t let they change the fields on server, so i decided to use acf-json.

    When i’m using the same theme, it works fine, but when i’m using child themes, the fields do not update.

    Testing my site i’ve found that when i’m using child themes, the fields are saved to “current” theme, even if the current theme is a child theme.

    Change the default save and load options, from “get_stylesheet_directory()/acf-json” to “get_TEMPLATE_directory()/acf-json”.

    The function get_template_directory() returns the main directory for the theme if is parent and the parent_directory if is a child theme, so now it works fine and i can control my fields only in the parent theme.
    Hope it can help you! 😉

  • Hi!
    I’m creating the field groups via wp-admin, on acf front-end.
    After, i’m exporting via exporting tool (from acf) and including on my functions.php.
    I’m using a network for many sites (government), so i need my custom fields defined on my theme, i can’t use json import/export process every time i need an update, for each site.

    The site where i’ve created my cfs is id 3, same on localhost and webserver.
    I can retrieve a lot of data correctly, but in some cases, i’ve got post-attachment-id instead of my return option.

    I’m in contact with the acf team to find the solution.
    Field Creation

  • Try to persist your object->ID always, try something like:

    
    <?php
    if(have_rows('my-repeater', mypostfather->ID) :
    while(have_rows('my-repeater', mypostfather->ID) : the_row();
    $my-son-object = get_sub_field('my-relational-post-object-field'); //return your related-post 
    $my-son-values = get_field('my-son-acf-value', $my-son-object->ID);
    endwhile;endif;
    ?>
    

    I think that your wp_reset_postdata($venue) is causing the problem.
    I don’t use setup_post_data on custom-post-type-objects like $video, $venue, $etc

  • You already got the post_object, you dont need to setup_postdata and in some functions you have to pass the id as integer, not a function (get_field)…

    So you can echo directly from the post_object, something like this:

    <?php if( have_rows('cast') ): ?>
            <ul class="events">
                <?php while ( have_rows('cast') ) : the_row(); ?>   
                    <li>
                        <?php $post_object = get_sub_field('choose_cast_members'); ?>
                        <?php if( $post_object ): ?>
                            <?php 
                              $thumbid = get_post_thumbnail_id($post_object->ID);
                              $thumb = wp_get_attachment_image_src( $thumbid ), 'thumbnail' );
                              $url = $thumb['0']; 
                            ?>
                                <?php //$post = $post_object; setup_postdata( $post_object ); //dont need to setup_post_data ?>
                                <a href="<?php echo get_permalink($post_object->ID);//here ?>"> 
                                    <img src="<?php echo $url; ?>" alt="<?php echo $post_object->post_title; //here ?>" />
                                </a>
                                <h3><?php echo $post_object->post_title; ?></h3>
                                <?php echo apply_filters('the_content', $post_object->post_content); ?>
                                <?php //wp_reset_postdata(); ?>
                        <?php endif; ?>
                    </li>
                <?php endwhile; ?>
                </ul>
    <?php endif; ?>
Viewing 6 posts - 1 through 6 (of 6 total)