Compatibility with “swicth_to_blog” function
-
I have a WordPress multisite, in a page I load posts from other blogs with the function “switch_to_blog()”
But the post content (title, content, qtranslate acf field…) is not returned correctly.
Example: blog with ‘it’ language get posts from blog with “ar” and “en” languages.
I have a loop foreach post ID, on this loop I tried this:
$title = get_post($id)->post_title; //Here I get back the full string [:ar]…[:en]///[:]
and this
$title = get_the_title($id); // Here I get back an empty string.However, for another blog (“it” blog get posts from blog with “cn” and “en” languages), I have the same title for both “en” and “cn” languages so the 2 codes above return the title correctly.
Is there a way when querying for a post field, to force one language and avoid the horrible string with qtranslate tags ? I didn’t find anything to achieve this. My only correct option here is to get the full string and use PHP regex to cut the string as I want.
Plugins used :
ACF Qtranslate : 1.7.22
QtranslateX: 3.4.6.8
- The topic ‘Compatibility with “swicth_to_blog” function’ is closed to new replies.