Support

Account

Forum Replies Created

  • We are you using a lot ACF blocks in gutenberg and we found an issue with it in the WP JSON API.

    When you are creating ACF blocks and copy them to other pages the blockID is the same.

    Then we have a function for the register_rest_field to get the blocks in the REST API so we can sync them to our frontend.

    We do so like this:

    `
    $blocks = parse_blocks( $post->post_content );

    FOR EACH BLOCKS

    acf_setup_meta( $block[‘attrs’][‘data’], $block[‘attrs’][‘id’], true );

    $fields = get_fields();

    acf_reset_meta( $block[‘attrs’][‘id’] );
    `

    When you ask for a batch pages in the REST API like this:

    https://domain.com/wp-json/wp/v2/pages/?page=9&per_page=3

    The block field for all the pages on the URL will have the exact same ACF values as the first page.

    The bug is in acf-value-functions.php

    – function acf_get_value (rule 91-92)
    – function acf_format_value (rule 143-144)

    Here you they are posting values to the store with this code:

    `
    // Update store.
    $store->set( “$post_id:$field_name:formatted”, $value );
    `

    The problem is the $post_id for ACF blocks is the blockId which is not unique if you copy ACF blocks from page to page.

    The solution would be to make the store something like this:

    `
    // Update store.
    $store->set( “$post_id:$block_id:$field_name:formatted”, $value );
    `

    This way you have the real post_id and the block_id and the store key will be unique.

  • We are you using a lot ACF blocks in gutenberg and we found an issue with it in the WP JSON API.

    When you are creating ACF blocks and copy them to other pages the blockID is the same.

    Then we have a function for the register_rest_field to get the blocks in the REST API so we can sync them to our frontend.

    We do so like this:

    
    $blocks = parse_blocks( $post->post_content );
    
    FOR EACH BLOCKS
    
    acf_setup_meta( $block['attrs']['data'], $block['attrs']['id'], true );
    
    $fields = get_fields();
    
    acf_reset_meta( $block['attrs']['id'] );
    

    When you ask for a batch pages in the REST API like this:

    https://domain.com/wp-json/wp/v2/pages/?page=9&per_page=3

    The block field for all the pages on the URL will have the exact same ACF values as the first page.

    The bug is in acf-value-functions.php

    – function acf_get_value (rule 91-92)
    – function acf_format_value (rule 143-144)

    Here you they are posting values to the store with this code:

    `
    // Update store.
    $store->set( “$post_id:$field_name:formatted”, $value );
    `

    The problem is the $post_id for ACF blocks is the blockId which is not unique if you copy ACF blocks from page to page.

    The solution would be to make the store something like this:

    `
    // Update store.
    $store->set( “$post_id:$block_id:$field_name:formatted”, $value );
    `

    This way you have the real post_id and the block_id and the store key will be unique.

  • Figured it out myself:

    
    jQuery(document).ready(function()
    {
    	jQuery(window).off("beforeunload", null);
    });
    
  • Create a Repeater field with a file upload field in it.

  • Just put it on a blue background and give the map opacity 0.8 or something in css?

  • Hello,

    This is not related to ACF this is because you are having the Google Map in a javascript tab.

    The problem is your map is loading in a div with display none so it can not determine the width and height.

    This is easy to solve to either load the map when the tab is visible. Or to give the tab not display: none; but give it position: absolute; and top: -9999px; or something.

  • Hello,

    Set the output of the image field to: “Image Array” in the ACF field set.

    Then you can view your images with custom size like this:

    
    <?php $image = get_field("image") ?>
    <img src="<?= $image["sizes"]["post-portrait-featured-image"] ?>" alt="<?= $image["alt"] ?>" />
    
  • Hi kkyang,

    You can do so by editing the capability of the options page.

    Set it to a capability only a super admin has

    For example:

    
    $options = acf_add_options_page(array(
    		"page_title"    => "Options",
    		"menu_title"    => "Options",
    		"menu_slug"     => "options-theme",
    		"capability"    => "manage_sites",
    		"redirect"      => false
    		));
    

    For more capabilities see:

    http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table

  • Hello Marcio,

    You can use the acf_form function as described here:

    http://www.advancedcustomfields.com/resources/acf_form/

    See this section “Editing a specific post”

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