Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00
- - - - - - -

Supporter timezone: America/Lima (GMT-05:00)

This topic contains 1 reply, has 0 voices.

Last updated by Andreas W. 2 weeks ago.

Assisted by: Andreas W..

Author Posts
April 7, 2026 at 9:47 am #17953330

adrienR-5

Hi WPML Team,

I'm reporting a bug where the WordPress media library shows different media depending on whether it's accessed from Bricks Builder or wp-admin. Media uploaded in one context becomes invisible in the other.

The root cause is in WPML_Query_Filter::posts_where_filter() (classes/query-filtering/wpml-query-filter.class.php, around line 144-151):

$requested_id = isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : false;
$post_language = $this->post_translations->get_element_lang_code($requested_id);
$current_language = $requested_id && $post_language ? $post_language : $this->sitepress->get_current_language();

When the wp.media modal fires wp_ajax_query-attachments, it sends the currently edited post's ID as post_id. WPML resolves that post's language and filters media to only that language. This overrides even wpml_switch_language('all') — there is no official way to bypass it.

Bricks Builder uses the standard wp_enqueue_media() and wp.media modal. It runs on a frontend URL (?bricks=run), so WPML's cookie-based language detection also uses a different cookie than wp-admin, compounding the issue.

The expected behavior is that the media library should show all media regardless of language when opened from a page builder, since media assets are typically shared across languages.

My current workaround is temporarily unsetting $_REQUEST['post_id'] and calling wpml_switch_language('all') on wp_ajax_query-attachments when the referer contains bricks=run. This works but it shouldn't be necessary.

Suggested fix: Either respect wpml_switch_language('all') even when post_id is present in the request, or provide a filter to override the language determination in posts_where_filter for attachment queries.

Environment: WPML Multilingual CMS (latest), Bricks Builder theme (latest), WordPress 6.x

Thanks for looking into this.

April 9, 2026 at 12:29 am #17957748

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

WPML will always use the original image that was uploaded in the site's default language and then sync it into other languages.

WPML will handle the media language depending on each admin's language. You can switch the language inside the media library in the top admin bar.

If the media is synced, you will see entries in all languages inside the media library.

You can sync media by going to WPML > Settings > Media Translation. If the option to auto-detect media is enabled, disable it. Then access the manual setup, mark the checkboxes for existing content, and start the process. Note that it might take a while
for WPML to sync the media into all languages.

Now, when it comes to Bricks, we have no influence on how this theme handles the media library. Expected behavior would be that you see in each language the media content that, in fact was synced inside the media library.

An expected behavior of showing all media for all languages in the current language is rather unexpected.

Best regards
Andreas

The topic ‘[Closed] Media library filtered by language inside Bricks Builder due to posts_where_filter hardcoded $_REQUE…’ is closed to new replies.