Support

Account

Home Forums Search Search Results for 'WPML'

Search Results for 'WPML'

topic

  • Solved

    get_field() for separate groups shows value from the same group??

    I have 2 groups within my block

    It all displays correctly and saves correctly. No issues.
    However, in my template I try to get the values and I get strange issues.

    
    var_dump(get_field('group_four_square_main_square_background'));
    var_dump(get_field('group_four_square_main_square_cta'));
    

    Both return the SAME values!
    var_dump

    Why?

    
    function init_four_square_fields() {
      acf_add_local_field_group([
        'key' => 'group_four_square',
        'title' => 'Four Square',
        'fields' => [
          [
            'key' => 'field_four_square_main_square_title',
            'label' => 'Title',
            'name' => 'four_square_main_square_title',
            'type' => 'text',
            'prefix' => '',
            'instructions' => '',
            'required' => 0,
            'conditional_logic' => 0,
            'wrapper' => [
              'width' => '100',
              'class' => '',
              'id' => '',
            ],
            'default_value' => '',
            'placeholder' => '',
            'prepend' => '',
            'append' => '',
            'maxlength' => '',
            'readonly' => 0,
            'disabled' => 0,
          ],
          [
            'key' => 'field_four_square_main_square_description',
            'label' => 'Description',
            'name' => 'four_square_main_square_description',
            'type' => 'textarea',
            'prefix' => '',
            'instructions' => '',
            'required' => 0,
            'conditional_logic' => 0,
            'wrapper' => [
              'width' => '100',
              'class' => '',
              'id' => '',
            ],
            'default_value' => '',
            'placeholder' => '',
            'prepend' => '',
            'append' => '',
            'maxlength' => '',
            'readonly' => 0,
            'disabled' => 0,
          ],
          [
            'key' => "group_four_square_main_square_cta",
            'label' => 'CTA',
            'type' => 'group',
            'layout' => 'block',
            'sub_fields' => [
              [
                'key' => 'link',
                'name' => 'link',
                'label' => 'Link',
                'type' => 'link',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => [
                  'width' => '50',
                  'class' => '',
                  'id' => '',
                ],
                'return_format' => 'array',
                'wpml_cf_preferences' => 2,
                'acfml_field_group_mode' => 'advanced',
              ],
              [
                'key' => 'class',
                'name' => 'class',
                'label' => 'Class',
                'type' => 'text',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => [
                  'width' => '50',
                  'class' => '',
                  'id' => '',
                ],
                'wpml_cf_preferences' => 0,
                'maxlength' => '255',
              ]
            ]
          ],
          [
            'key' => "group_four_square_main_square_background",
            'label' => 'Main Square Background',
            'type' => 'group',
            'layout' => 'block',
            'sub_fields' => [
              [
                'key' => 'type',
                'label' => 'Type',
                'name' => 'type',
                'type' => 'radio',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => [
                  'width' => '50',
                  'class' => '',
                  'id' => '',
                ],
                'choices' => [
                  'image' => 'Image',
                  'video' => 'Video',
                  'color' => 'Color',
                  // 'embed' => 'Embed video',
                ],
                'allow_null' => 0,
                'other_choice' => 0,
                'default_value' => 'color',
                'layout' => 'horizontal',
                'return_format' => 'value',
                'save_other_choice' => 0,
                'wpml_cf_preferences' => 0,
                'acfml_field_group_mode' => 'advanced',
              ],
              [
                'key' => 'image',
                'label' => 'Image',
                'name' => 'image',
                'type' => 'image',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => [
                  [
                    [
                      'field' => 'type',
                      'operator' => '==',
                      'value' => 'image',
                    ],
                  ],
                ],
                'wrapper' => [
                  'width' => '50',
                  'class' => '',
                  'id' => '',
                ],
                'return_format' => 'array',
                'preview_size' => 'full',
                'library' => 'all',
                'min_width' => '',
                'min_height' => '',
                'min_size' => '',
                'max_width' => '',
                'max_height' => '',
                'max_size' => '',
                'mime_types' => '',
              ],
              [
                'key' => 'video',
                'label' => 'Video',
                'name' => 'video',
                'type' => 'file',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => [
                  [
                    [
                      'field' => 'type',
                      'operator' => '==',
                      'value' => 'video',
                    ],
                  ],
                ],
                'wrapper' => [
                  'width' => '50',
                  'class' => '',
                  'id' => '',
                ],
                'return_format' => 'array',
                'library' => 'all',
                'min_size' => '',
                'max_size' => '',
                'mime_types' => '',
              ],
              [
                'key' => 'color',
                'name' => 'color',
                'type' => 'select',
                'choices' => [],
                'conditional_logic' => [
                  [
                    [
                      'field' => 'type',
                      'operator' => '==',
                      'value' => 'color',
                    ],
                  ],
                ],
              ]
            ]
          ],
        ],
        'location' => [
          [
            [
              'param' => 'block',
              'operator' => '==',
              'value' => 'acf/four-square',
            ],
          ],
        ],
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
      ]);
    }
    
    add_action('acf/init', 'init_four_square_fields');
    
  • Solved

    ACF Frontend Form: add new post multilingual (WPML)

    A new multilingual post (2 languages, de/en) is to be created in a frontend form.
    WPML is used throughout the site for multilingualism.

    A new post in one language can easily be created with ACF (ACF pro) frontend form-
    However, the new post should always be created in both languages (from the frontend) at the same time.
    How can I achieve this?

  • Solved

    FrontEnd Form add new post mulitlanguage (WPML)

    A new multilingual post (2 languages, de/en) is to be created in the frontend.
    WPML is used throughout the site for multilingualism.

    A new post in one language can easily be created in the frontend with ACF (ACF pro).
    However, the new post should always be created in both languages (from the frontend) at the same time.
    How can I achieve this?

  • Unread

    How to translate custom fields with WPML

    Hello, can someone tell me how to translate the custom fields with WPML, Spanish and English appear the same?

    Imagen

  • Unread

    Update multiple values in relationship field not possible

    Hello,
    I am using Advanced Custom Fields PRO Version 6.2.7

    Recently I have noticed that when I want to update a relationship field with multiple values, the whole ARRAY is not saved, but only the first value of the ARRAY.

    I have used this code as a test:
    update_field('menu', array(123,456), $post_id);

    This is the output with var_dump:
    int(123)

    These are my settings for the relationship field:
    {
    "key": "field_60c789afded44",
    "label": "menu",
    "name": "menu",
    "aria-label": "",
    "type": "relationship",
    "instructions": "",
    "required": 1,
    "conditional_logic": 0,
    "wrapper": {
    "width": "",
    "class": "",
    "id": ""
    },
    "wpml_cf_preferences": 1,
    "post_type": [
    "product"
    ],
    "taxonomy": [
    "product_cat:new"
    ],
    "filters": [
    "search",
    "taxonomy"
    ],
    "elements": "",
    "min": "",
    "max": "",
    "return_format": "id",
    "bidirectional_target": []
    },

  • Solving

    Need to upgrade Pro Version

    I just purchase ACF Pro and just want to know if it is compatible with ELEMENTOR, WPML & HOUZEZ theme. As before I face a-lot of errors due to upgrading other plugins.
    My website URL : binayah.com

  • Helping

    switch_to_blog problem with Wpml

    hello, i’m using the following code to retrive informations from other sites in our multisite installations.


    switch_to_blog(2);
    $my_field = get_field('my_field', 'option');
    restore_current_blog();

    The website executing the code has WPML installed.
    Surprisingly the code above works fine if called from the main language of the site, but returns null if called from a page in different language
    eg: works if called from /siteX/ but not if called from /siteX/es/

    Do you know any solution for this?
    Thanks!
    Al

  • Unread

    Translation options not showing by creating new acf fields

    Hello,

    We are using WPML and something broke on the website.
    Translation options not showing by creating new acf fields.

    Please give me advice how it can be fixed.

  • Solved

    Relationship field showing "No matches found" with WPML

    Hi

    I have a similar problem as described here.

    Wordpress 6.1.1 – latest
    ACF Pro 6.0.7 – latest
    WooCommerce 7.4.1 – latest
    WPML Multilingual CMS 4.5.14 – latest

    I have an options-page where I can set a featured prodct and some selected bestsellers. This fields are done with ACF Post Object for the featured product and with ACF Relationship for the bestsellers.

    Main problem is, that my page is multilingual but not the products. the products are in german only. For this I have set the “Post Type Translation” in WPML for the Post-Type product to “Translatable – use translation if availlable or fallback to default language”. With this setting I can reach my products in all languages even though thea are not translated.

    Now on my options-page I can select products on my default language (german).
    When I change to another language (En and Fr) there ist a message that says “No matches found” and I am not able to choose products for that Post Type.

    What am I missing?
    Does anyone has an idea where to search and what I can try to select products made in another language?

    best regards
    roman

  • Helping

    ACF & WPML wrong order of Post Object

    I have a Post object registered to posts(which are non-translatable), and the field is also non-translateable.

    Once you select some posts in the registered Post Object, it’s automatically shared between the post in all languages, but the order of the posts that are selected in the Post Object fields are always in a different order. How can I get the field with the values always in the order that they are selected or sorted in the field?

  • Unread

    ACF Forms and WPML

    Hi,
    I have a site where users can submit “small notes” from a frontpage form created in ACF.
    I would like these “notes” to be duplicated into the other languages I have on the site, but nomather what I do, the only things duplicated are standard WP-fields (title, author etc). None of my ACF are included in the automatic duplication-process! šŸ™

    The code I use to duplicate:

    add_action( 'wp_insert_post', 'my_duplicate_on_publish' );
    function my_duplicate_on_publishh( $post_id ) {
           
        $post = get_post( $post_id ); 
            
        // don't save for autosave
        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
            return $post_id;
        }
        // dont save for revisions
        if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
            return $post_id;
        }
         
          
         if ( isset( $post->post_type ) && $post->post_type == 'custom-post' ) {
             
            // we need this to avoid recursion see add_action at the end
            remove_action( 'wp_insert_post', 'my_duplicate_on_publish' );
             
                // make duplicates if the post being saved
                // #1. itself is not a duplicate of another or
                // #2. does not already have translations
             
                $is_translated = apply_filters( 'wpml_element_has_translations', '', $post_id, $post->post_type );
             
                if ( !$is_translated ) {
                    do_action( 'wpml_make_post_duplicates', $post_id );
                }
         
        }
        // must hook again - see remove_action further up
        add_action( 'wp_insert_post', 'my_duplicate_on_publish' );
    }
  • Helping

    ACF not creating underscore fields in the database for translated pages

    Hello!

    I have a peculiar problem with ACF not working correctly with WPML plugin. Here is the description of the problem:

    The wrong behavior of ACF plugin in tandem with WPML results in repeater fields not being stored correctly in the database, meaning that they cannot be displayed correctly on the front-end. When trying to fetch some information from a repeater field, present on a page, that is a translation (WPML) of another page, the result will not be an expected array of data, but a string which represents the number of rows in the repeater. The problem occurs only on the pages, which are translations of other pages and for all repeater fields, regardless of when it was added. There is one found solution for the problem. If you go to the original page (WPML) and change in any way a repeater, it will get fixed for the translation page as well and start working as expected. But that only works for the repeaters that were edited in any way on the original page. Meaning that the problem lies not in updating the database, but in creating a mandatory record in the first place.

    Example of database info on a broken page:
    https://imgur.com/pc3fNmq (first attachment)

    Example of database info on a correctly working page:
    https://imgur.com/tdOn1kO (second attachment)

    The correct one has an additional ā€œunderscore fieldā€ _faq_custom that points to the field that holds the data so that it can be fetched.

    Additional information
    If we manually add this ā€œunderscore fieldā€ (in this case, _faq_custom) to the database, everything starts working fine.

    After saving FAQ fields on the page in the original language we can see the following in the database
    https://imgur.com/b8BHgbf (third attachment)

    It adds not only _faq_custom field, but a bunch of other ones as well, that weren’t properly added before.

  • Helping

    Sync of Definitions from json -> DB is Slow

    When syncing ACF json field definition files between our dev and prod environments, I find the sync process to be really slow at times, and can time out and cause a 50X response.

    There appears to be a connection between using a shorter field name in ACF and the length of time that the import process takes, due to the length of some of the content stored in some of our ACF fields, and the number of records we have in the DB.

    I’ve found this to be caused by the query in the update_existing_subfields function in the WPML_ACF_Field_Settings class on line 256:

    $query = "SELECT * FROM {$wpdb->postmeta} WHERE meta_key LIKE %s";

    Suggested Fix:
    From what I can see, the update_existing_subfields function is only called by ACF, and only from a single place, in function update_field_settings.

    The DB field meta_value included in the output from this query is not used, and in our case it can cause memory usage to rapidly expand and cause PHP to Fatal Error due to a case of Out of Memory.

    Therefore, it should be safe to update the query and avoid the meta_value content. On this basis, I’ve found that simply changing line 256 to:

    $query          = "SELECT post_id, meta_id, meta_key FROM {$wpdb->postmeta} WHERE meta_key LIKE %s";
    

    is enough to fix our issues with the Sync Process, and indeed make the process really fast once again.

  • Solving

    Translation preferences changes after synchronize with json

    Problem:
    After synchronize fields with JSON files, the updated fields Translation preferences turns to “copy” mode instead keeping the original option “copy once”.

    How to repeat the issue:
    On localhost update some fields, all with Translation preferences = “copy once”.
    Upload folder /acf-json/ to production server
    On production server Sync fields.
    Result: fields that had Translation preferences = “copy once” became “copy” mistakenly.

    WP 6.0.1
    Advanced Custom Fields PRO Version 5.12.3
    Advanced Custom Fields Multilingual 1.4.0
    WPML Multilingual CMS 4.5.4

    Thanks for your help

  • Helping

    get_field_object and WPML

    Friends, hello. The answer was not found, I am sure that someone was able to solve this problem.

    The problem is this: I have a field with a choice of different values.
    The site is in two languages, there will be more in the future.
    In the field settings, I have created values.
    I can get

    <?php $project_scope = get_field_object( "key_12345678" )["choices"]; ?>
     <select name="project_scope" class="uk-select _req">
    <?php foreach ( $project_scope as $key => $value ): ?>
              <option value="<?php echo $key ?>"><?php echo $value ?></option>
    <?php endforeach; ?>
    </select>

    And it works. But how do you make someone else choose meanings in another language?

    The key is unique and is used only for 1 field. This is true and understandable.

    I tried

    <?php//   GET all value from select FROM ACF SETTING
    $project_scope = get_field_object( acf_get_field("project_scope")["key"] )["choices"]; ?>
     <select name="project_scope" class="uk-select _req">
    	<?php foreach ( $project_scope as $key => $value ): ?>
                     <option value="<?php echo $key ?>"><?php echo $value ?></option>
    	<?php endforeach; ?>
     </select>

    I still get the values from the default language. And not from which one is active.
    What parameter would I pass to get the value from this field but from another language?

  • Unread

    get_field and get_fields only working with integer IDs

    On non-default language pages, the get_fields() and get_field() functions are only working if the post ID is passed as an integer.

    ACF Pro 5.11.3
    ACF Multilingual 1.9.1
    WPML Multilingual CMS 4.4.12
    WordPress 5.8.2

  • Helping

    How to assign random ID to headings (h1,h2,h3,h4 exc) in AFC WYSIWYG field?

    How to assign random ID to headings (h1,h2,h3,h4 exc) in AFC WYSIWYG field?
    I need to print content in various languages without using polylang or WPML, so i’ve decided to build ACF WYSIWYG fields, in which i put content in various languages. My post are printed by elementor templates depending on category, so i can use tabs widget to switch between ACF field.
    The facts is that i use also TOC widget to anchor various chapters by their headings, but when template prints content, the anchor headings are progressive and the same for all languages.

    I’ve managed to solve this manually, writing by myself an ID into <h> tag, in order to let anchors work, but i need to automate this process.

    I’ve found some snippets to put into functions.php but only for POST CONTENT, not for ACF fields.

    Thanks in advance to all

  • Solving

    WPML + ACF creates a conflict between languages

    Hi, I already made a post about this but I feel like it got deleted because it is neither on the forum nor my profile.

    Anyway, I currently have a bug on a client’s website with WPML regarding fields that keep the original text after saving.

    Here’s how the bug occurs:
    – First I enter the content in french (the default language) and I save it
    – Next I create a copy of the page in english
    – I translate my fields in english and save again
    – By this point, everything seems fine until I refresh the page. What happens is that some fields that are Clones keep the french translation and I can never change it to english.

    Also, when I try to change the settings of the field from “Copy” to “Translate”, it always goes back to “Copy” after saving.

    Is it because of a conflict in the database?

    Let me know if you need any more information.
    Thanks!

  • Solving

    Flexible content layout duplication for multilanguage

    Hi iam using WPML and ACF plugin on my website. My ACF field group consist a flexible content under which there are numerous layouts. I created a new layout for a particular language. But now i want to duplicate the new layout for other languages also. But don’t have any idea on how to do this. Iam new to wordpress. Can any suggest me?

  • Unread

    ACF showing placeholders instead of the content in duplicated pages with WPML

    Hi all,

    I hope someone can help me here.
    I have a website that was perfectly working until a few days ago. However, after the last update, I noticed that on the duplicated pages for the multicountry/multilanguage websites, the fields show the placeholder and not the actual content, which is regularly present in the backend. Everything work just fine in the primary language.

    I tried everything, changing options in general rules (both on ACF and WPML). Nothing.
    I noticed a message about the Nginx.conf asking to restart the nginx server, contacted the service provider, reloaded the server but nothing.

    I’m running out of ideas here, and I need to solve this.

    Thank you in advance for any piece of advice you can give me.
    Best
    Ste

  • Solving

    Translating ACF form field labels in frontend with WPML

    A follow-up for this forum post about translating form field labels with Polylang. This time with WPML String Translation.

    add_action('init', function(){
        if (!is_admin()) {
            foreach (acf_get_field_groups() as $group) {
                $fields = acf_get_fields($group['ID']);
                if (is_array($fields) && count($fields)) {
                    foreach ($fields as $field) {
                        do_action('wpml_register_single_string', 'ACF Labels', $field['label'], $field['label']);
                        do_action('wpml_register_single_string', 'ACF Messages', $field['message'], $field['message']);
                        do_action('wpml_register_single_string', 'ACF Instructions', $field['instructions'], $field['instructions']);
                    }
                }
            }
        }
    });
    
    add_filter('acf/load_field', function (array $field) {
    	$field['label'] = apply_filters('wpml_translate_single_string', $field['label'], 'ACF Labels', $field['label']);
    	$field['message'] = apply_filters('wpml_translate_single_string', $field['message'], 'ACF Messages', $field['message']);
    	$field['instructions'] = apply_filters('wpml_translate_single_string', $field['instructions'], 'ACF Instructions', $field['instructions']);
    	return $field;
    });
  • Unread

    Cannot return get_field() in translated language for terms

    I am trying to return the url of an icon (implemented with ACF + WPML) from a translated custom taxonomy term:

    @php
    $terms = get_terms(array(
    'taxonomy' => 'parcours',
    'hide_empty' => true,
    ));
    @endphp
    
    @if (!empty($terms))
    @foreach ($terms as $term)
    @php
    $id = $term->term_id;
    $taxonomy = $term->taxonomy;
    $slug = $term->slug;
    $name = $term->name;
    $image = get_field('route_icon', $taxonomy . '_' . $id);
    @endphp
    
    @php echo $image @endphp
    
    @endforeach
    @endif

    No matter what i have tried (wpml_object_id included). The image variable is empty in the translated site only. The variable is returning the expedted data in the original language and everything is working well. Also the id variable is returning the correct translated id as expected.

    Am I doing something wrong in ACF? Thanks a lot for your help.

  • Solving

    delete_row() with WPML

    Hello,

    I’ve having an issue trying to delete a row within a Flexible Content -> Repeater subfield. What I need to do is if a sub_field to the Repeater doesn’t exist remove the entire row from the Repeater. I found on the documentation that delete_row() should work but it’s simply not no matter if I use the field name or the key. I’ve also tried to use delete_sub_row() also to no avail.

    I know there are some issues with flexible content and WPML but I’m starting to believe that there is an issue here as well. Has anyone run into this issue before as well or am I doing something wrong?

    Obviously, I’ve trimmed this code down but the information below is what I’m having issues with.

    if ( get_row_layout() == ‘grid_large’ ):
    if ( have_rows(‘blocks’) ) :
    while ( have_rows(‘blocks’) ) : the_row();
    $link = get_sub_field(‘link’);
    if(!$link){
    delete_row(‘blocks’, $i);
    }

  • Helping

    Removing field group that shows on page, but not in Custom Fields admin

    Hi there,

    I’ve made a gallery and added it to the homepage. I then used WPML duplicate it to two other languages.

    Somehere I think something went wrong. I’ve deleted all the field groups in the ACF admin, but the gallery still shows on the page edit screen. It doesnt show the edit group cog when I hover over it either.

    Any way to remove this via a function or something? I can get the field group ID from console I think.

    Thanks in advance.

  • Helping

    Massive issues with ACF Multilanguage and WPML

    Hey guys, I have made this support request but I am not just thinking i will create two tabs with 2 groups of fields on each page, one for french and one for english and just write my own template files for translations. I am not sure if it is WPML or the WPML ACF Multilanguage plugin or what but this seems like legit the worst software (not ACF… I love ACF… I mean WPML) that I have ever used.

    I can only assume that WPML dev’s haven’t spoken with ACF Dev’s in a long time. Is this now deprecated?

    https://wpml.org/forums/topic/acf-mult-issues-copy-once-fields-randomly-showing-up-blank-on-translated-pag/#post-8716585

    Has anyone else ran in to this?

    On some pages, just random fields are blank and others are fully populated. This is extremely frustrating. The fields are showing on the front end, just not the back. so everytime you save a page you have to repopulate all of the meta boxes or it will overwrite your content with ”.

Viewing 25 results - 1 through 25 (of 495 total)