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
- 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 -
- 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 -

Supporter timezone: Asia/Dhaka (GMT+06:00)

This topic contains 7 replies, has 2 voices.

Last updated by Prosenjit Barman 1 year, 1 month ago.

Assisted by: Prosenjit Barman.

Author Posts
March 7, 2024 at 2:43 am #15381996

佳樹 岡田

Hello.
(I translated the text at DeepL, so sorry if it's not clear)

1. language switcher URL does not work correctly

do_action('wpml_add_language_selector');
The URL linked to the language switcher output by the above code shows incorrect URLs.

Example: hidden link
Correct: hidden link

This event occurs only on article pages of custom post types.
Also, the following error message is displayed when accessing the URL that is supposed to be correct.
"There has been a critical error on this website."

2. Translated pages do not appear in the archive

Only translated pages are not displayed in the taxonomy archive of custom post types or in the article list view using WP_Query.
(This may be related to the article page error above.)

If you set "Post Types Translation" to "only show translated items", the articles are not displayed, and if you set "use translation id~", only untranslated pages are displayed.

It would be helpful to know the cause.
Thank you in advance.

March 7, 2024 at 12:01 pm #15384037

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thanks for contacting WPML Support.

I understand the issue you're having. In an attempt to directly observe the issue, I tried accessing your website. However, due to browser login protection, I was unable to proceed with the examination.

Regarding the Fatal error you mentioned when accessing a specific link, could you please activate the WordPress Debug log to see if any errors are being logged as a result? For guidance on enabling the debug log, you might find this tutorial helpful: https://wpml.org/documentation/support/debugging-wpml/.

If you encounter any errors in the log, kindly copy them and provide the details in your next message. This will allow me to conduct a more thorough analysis and advise you on the subsequent steps.

Additionally, the issue with Translated articles not appearing in the Archive may stem from how the WP_Query is being implemented. Would you be able to share the relevant code snippet? Although custom code support falls outside our standard support parameters, I am willing to review the code and offer suggestions on how to ensure translated posts are visible in the archive.

I look forward to your reply and am eager to offer further assistance.

Best regards,
Prosenjit

March 7, 2024 at 1:54 pm #15384694

佳樹 岡田

Thanks for the reply.
I'll send you the WP_Query source code first, as I can't set up a debug log right away.

---------------------------------------

$shop_all_args = array(
'posts_per_page' => '-1',
'post_status' => 'publish',
'post_type' => 'shop',
'meta_key' => 'yomigana',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'comingsoon',
'value' => '0',
'compare' => '=',
'type' => 'NUMERIC',

),
),
);

$shop_all_query = new WP_Query($shop_all_args);

---------------------------------------

If you can find the cause, please let me know.

Best regards.

March 7, 2024 at 9:48 pm #15386925

佳樹 岡田

Hi.
We checked the debug log and found that the following information was repeatedly recorded.

---------------------------------------

[07-Mar-2024 21:44:59 UTC] PHP Deprecated: Creation of dynamic property Whip_RequirementsChecker::$configuration is deprecated in /var/www/html/wp-content/plugins/sitepress-multilingual-cms/vendor/yoast/whip/src/Whip_RequirementsChecker.php on line 37
[07-Mar-2024 21:44:59 UTC] PHP Deprecated: Creation of dynamic property Whip_RequirementsChecker::$messageManager is deprecated in /var/www/html/wp-content/plugins/sitepress-multilingual-cms/vendor/yoast/whip/src/Whip_RequirementsChecker.php on line 38

March 7, 2024 at 9:58 pm #15386935

佳樹 岡田

>do_action('wpml_add_language_selector');
>The URL linked to the language switcher output by the above code shows incorrect URLs.

>Example: hidden link
>Correct: hidden link

>This event occurs only on article pages of custom post types.
>Also, the following error message is displayed when accessing the URL that is supposed to be correct.
>"There has been a critical error on this website."

The error text when accessing the "Correct URL" above is as follows.

---------------------------------------

[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 40
[07-Mar-2024 21:49:46 UTC] PHP Deprecated: nl2br(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 41
[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 42
[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 46
[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 47
[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 48
[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 49
[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 50
[07-Mar-2024 21:49:46 UTC] PHP Warning: Trying to access array offset on value of type null in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 51
[07-Mar-2024 21:49:46 UTC] PHP Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in /var/www/html/wp-content/themes/kitte-theme/single-shop.php:56
Stack trace:
#0 /var/www/html/wp-content/themes/kitte-theme/single-shop.php(56): array_filter(NULL)
#1 /var/www/html/wp-includes/template-loader.php(106): include('/var/www/html/w...')
#2 /var/www/html/wp-blog-header.php(19): require_once('/var/www/html/w...')
#3 /var/www/html/index.php(17): require('/var/www/html/w...')
#4 {main}
thrown in /var/www/html/wp-content/themes/kitte-theme/single-shop.php on line 56

---------------------------------------

The code in the relevant section was reading the Custom Field data created in ACF.

---------------------------------------

$info = get_field('info');
$info_judge = array_filter($info); // line 56

---------------------------------------

I would be happy to know anything you can tell me with the above information.
Best Regards.

March 8, 2024 at 9:07 am #15387846

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi,
Thank you for the update.

Let's tackle the issues one at a time. Based on the error log you've provided, there doesn't seem to be any critical errors or warnings stemming from the WPML plugin or its extensions. The fatal error you're encountering points to an issue within your theme's PHP code.

Specifically, the error at line 56 in the `single-shop.php` file arises because the `array_filter()` function expects an array, but instead, it's receiving a null value. This discrepancy could be the result of a failed database query, an unexpected function return value, or another operation that didn't produce the expected array.

To resolve this error, it's necessary to trace back and determine why the expected array is turning up as null. This might involve examining earlier segments of your code where this variable is initialized or modified. Please note, that addressing issues related to custom code, themes, or plugins falls outside our standard support scope. Therefore, we suggest consulting with the developer who wrote the code for more direct assistance. They should be able to identify the root cause and help rectify the issue.

For the issue with the Translated posts not appearing in the Archive - Thank you for sharing the WP_Query code. From the code, I noticed that you've defined a meta_key named 'yomigana' and in the meta query, you've defined a key named "coming soon". Could you please ensure that the same Meta that you've defined are also set for the translated post? If you want the same Meta information to appear in the translated posts, please go to "WPML > Setting" and search for both keys in "Custom Field Translation" and "Custom Term Meta Translation" section.

If they appear in the result, set the translation preference for both keys to "Copy", and update the default page and the translation as well.

If the translated posts still not showing in the archive, you can add the following argument right after "'order' => 'ASC'," in the WP_Query code:

'suppress_filters' => true,

I hope the information above helps. Please feel free to let me know if you need further assistance. I'll be happy to help.

Best regards,
Prosenjit

March 11, 2024 at 9:55 am #15394030

佳樹 岡田

I reviewed the Custom Field settings as you suggested and the error is gone. Thanks!
Now I have another problem: the URL for the language switcher.

As shown below, incorrect link URLs are output only on custom post type article pages.
(Base language is Japanese)
What could be the cause of this problem?

*URLs are supposed to be assigned by language, but they are all assigned "en".

------------------

<link rel="alternate" hreflang="ja" href="hidden link" />
<link rel="alternate" hreflang="en" href="hidden link" />
<link rel="alternate" hreflang="ko" href="hidden link" />
<link rel="alternate" hreflang="zh-hans" href="hidden link" />
<link rel="alternate" hreflang="zh-hant" href="hidden link" />
<link rel="alternate" hreflang="x-default" href="hidden link" />

------------------

<div class="wpml-ls-statics-shortcode_actions wpml-ls wpml-ls-legacy-list-horizontal">

</div>

------------------

Best regards,

March 12, 2024 at 4:12 am #15397675

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,

Thank you for the update. Glad to hear that the suggestions helped! 🙂

Regarding the problem with links - Could you please check and ensure that the posts you've within the "Shop" post type have been translated into other languages? If not, please translate them and check again.

If they have been translated, then please try the following:

- Please go to WPML > Support > Troubleshooting
- Click on these buttons:
-- Disable cache for language switcher templates
-- Select "Shop" post type from the Dropdown and click on Synchronize posts taxonomies
-- Clear the cache in WPML
-- Assign translation status to duplicated content
-- Set language information
-- Fix post type assignment for translations

Once the troubleshooting is completed, please clear the caches from your site and browser and check the posts in the Shop post type again.

Let me know how it goes. I will be happy to help if you need further assistance in this matter.

Best regards,
Prosenjit

The topic ‘[Closed] Incorrect link URL in selector and 404 when translating custom post type’ is closed to new replies.