Skip Navigation

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
- 8:00 – 15:00 8:00 – 15:00 8:00 – 15:00 8:00 – 15:00 8:00 – 15:00 -
- 16:00 – 17:00 16:00 – 17:00 16:00 – 17:00 16:00 – 17:00 16:00 – 17:00 -

Supporter timezone: Europe/Rome (GMT+02:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Alejandro 1 year, 6 months ago.

Assisted by: Alejandro.

Author Posts
November 8, 2023 at 12:11 pm #14756163

tobiasH-27

Hello,
We have a multi site that is using WPML (the lastest version), with DE as primary language and FR as secondary

We are having 2 issues.

1. On the main site we are getting all the posts from subsites using WP_Query. It's working fine on the main language but on FR we are getting this critical error (Attempt to assign property "object_id" on bool), check screenshot attached. Most of the subsites are displayed but some are throwing this error.

Here is the code that we are using

foreach ( $sites as $site_id ) {
            switch_to_blog( $site_id );
            $args = [
                'post_type'      => 'post',
                'posts_per_page' => - 1,
                'post_status'    => 'publish',
            ];
            $the_query = new WP_Query( $args );

            ...

            restore_current_blog();
        }

2. For some posts from the subsites on the on the main language DE wp_get_post_terms is not returning "category" but "translation_priority" as terms, check screenshot attached.

$categories   = wp_get_post_terms( get_the_ID(), 'category' );
Screenshot 2023-11-08 at 1.07.19 PM.png
Screenshot 2023-11-08 at 12.49.46 PM.png
November 9, 2023 at 12:28 pm #14766687

Alejandro
WPML Supporter since 02/2018

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hello

we can't dig much into the custom code you created because it's out of the scope of our support, however i wonder if you've checked out our hooks: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

I suspect that you might need to use them or at least make sure you set a correct value in:

supress_filters

(it's by defaul set to false, so you might want to set it to true).

Can you try that and see if that works?

November 9, 2023 at 3:41 pm #14769397

tobiasH-27

Hi Alejandro,

Thanks for you reply.

We added the supress_filters parameter to the WP_Query arguments but it didn't fixing anything.

In the code that I have attached above we are just looping all the sites and running a WP_Query to get the posts from each one of those sites to the main site.

The issue is that WP_Query or get_posts are throwing this error, Critical error (Attempt to assign property "object_id" on bool).

November 9, 2023 at 4:27 pm #14769961

Alejandro
WPML Supporter since 02/2018

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

ok, then tell me something else. this code, is added to a plugin, an integration with something, to the functions.php or something else?

Would it be possible to have, say a clean staging site with this code added? with nothing else but the code and without plugins or just wih the ones needed to run the code?

I can't debug the code for you but if i have a site on a minimal or clean installation (with just the minimal set of variables needed to recreate the problem without interference by plugins, themes or other custom code) then i can try to take a look and see if i can find any clue about what's going on.

November 14, 2023 at 4:15 pm #14800755

Alejandro
WPML Supporter since 02/2018

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

1) Can you please tell me in what file and directory are you seeing this?
2) Can you tell me the URL where i can test it on the front-end?

November 14, 2023 at 4:39 pm #14800973

tobiasH-27

Hello,

The file used for the logic of this component is this on
/wp-content/themes/vif/app/View/Components/NewsOverview.php

Here are the urls where you can check it

DE: hidden link
FR: hidden link

November 15, 2023 at 10:44 am #14807275

Alejandro
WPML Supporter since 02/2018

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hello!

I checked the code and while it's way outsidethe scope of our support i saw that it was indeed working ok, and you can see that too when most of the posts retrieved are ok.

the wrong language issue was likely because of the suppress_filters. that arg was removed when i checked it and i couldn't see that problem, however the fact that the problem only happens in some very specific posts is a clue. maybe those posts do not have a translation? maybe they do not have a category selected?

Frankly i'm a bit confused about the code since you mentioned it's pulling content from other subsites, however, at least for the content that is failing, they exist in the vif subdomain, they have the same categories same slugs and everything so let's do the following:

- let's pick a reference post: hidden link (in all its languages)
- Check how it differs from other posts that ARE showing the correct category
- Maybe rename the categories and slugs to something that won't create too much problem on the view (add a character or remove one) and make every language different for those categories so we can understand where is the site pulling them from on other posts that are working correctly.

Then check again to see if you get other clues about them and let me know.

November 15, 2023 at 1:15 pm #14808743

tobiasH-27

Hello,

Setting 'supress_filters' => true, doesn't fix the issue. Still the wrong category term label is rendered on the page (each one of those posts has a category term assigned)

November 15, 2023 at 5:39 pm #14819509

Alejandro
WPML Supporter since 02/2018

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

I know it doesn't and that's not what i asked, in fact i believe that's why you say german posts in the other language.

I asked you something else, so please re-read my last message and let me know how it goes.

I really want to help you but you're working with custom code on a multisite with different sites that all have the same categories, same slugs in different subsites so it's very difficult for me to even check it out without the info that i requested.

Regards.

The topic ‘[Closed] Critical error (Attempt to assign property "object_id" on bool)’ is closed to new replies.