ACF и Qtranslate-X

It was not so long ago, I took on the task of improving the site on WordPress, it had the Qtranslate-X plugin installed and it was necessary to add a text input field for certain page templates. The problem arose because the ACF plugin was fresh, and Qtranslate-X is a bit outdated and the ability to select a language was not added to the created field.

Fixing this problem with the Qtranslate-X plugin turned out to be elementary. All that was needed was to create a hook and add a specific class when creating a new field.

Follow the steps below, to make ACF and qTranslate-X friends:

  1. Before we get to the ACF fix part, you need to add the class name to the fields, which you want to use in multiple languages. Go to the qTranslate-X settings page (Settings > Language) in the WordPress admin and click on the "Integration" tab.
  2. Scroll down and find the "Custom Fields" setting. You will see the input field "class". Here you can add class name for custom fields, which you want to use in multiple languages. In our case, we used the class name "transhable", as shown in the screenshot below. After adding the class name, save the changes.
    ACF и Qtranslate-X
  3. Now let's move on to the ACF field settings. For each field, which you want to make multilingual, add class name, added in step 2, in the "class" field in the "Wrapper Attributes" section, as below:
    ACF и Qtranslate-X
  4. Almost done. In ACF field settings you can't add class name directly to input field or textarea field, which you would like to use in multiple languages. So instead we added it to the wrapper in step 3, and now we need to use ACF filter, to add it to the input or to the text area itself. In your theme's functions.php file, add the following snippet:
     
  5. That's all. Now, when you use the qTranslate language switcher on the post edit screen, your "translatable" fields will be multilingual, which will allow you to add content in different languages. I hope, it will help those of you, who uses Advanced Custom Fields and qTranslate-X together. If you have questions or feedback, let us know in the comments below. In our projects we use a different plugin, but we often encounter this in revisions, I think a lot of people will find this article helpful..

Buy WordPress hosting
WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal