Home › Forums › Bug Reports › Incompatibility with Polylang
Hi,
I recently stumbled upon an incompatibility bug of ACF with the multi-language plugin “Polylang”(http://wordpress.org/plugins/polylang/).
By using a relationship-field the posts didn’t appear anymore. I was able to identify the origin of the bug with the help of Firebug: ACF was not able to fetch the AJAX results, because there was a PHP-error thrown.
The error message pointed to /advanced-custom-fields/core/fields:173, where ACF provides support for WPML. At the moment this line only checks the existence of $options[‘lang’] and tries to run a method of $sitepress. The problem is that Polylang seems to use the same option. It would be sufficient to just check if $sitepress really exists:
if( $options['lang'] && isset($sitepress) )
Greetings Maik
I think the conditional statement has to occue AFTER the global $sitepress statement, so perhaps this would be the fix:
// WPML
if( $options['lang'] )
{
global $sitepress;
if( !empty($sitepress) )
{
$sitepress->switch_lang( $options['lang'] );
}
}
Can you try that and let me know if it works?
Thanks
E
Hi @elliot,
you are absolutely right. I missed the global $sitepress statement underneath.
I can confirm that your fix works and solves the problem.
Greetings Maik
I have WordPress 3.8 / ACF 4.3.4 and PolyLang 1.3.1.
I can see the fix above included in core/fields/relationship.php but still cannot get Polylang to work with ACF.
When I look in the database, it has the fields, but when I view the page, any advanced custom fields are not displaying in correct language, so something still isn’t being mapped properly.
what additional info would you all need to help?
thanks much
William
If you are able to jump into the relationship field file and do some debugging, that would be great!
Perhaps you can find the line which does not produce the desired result?
Other than that, I will need to do some testing myself.
Thanks
E
The topic ‘Incompatibility with Polylang’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.