This thread is resolved. Here is a description of the problem and solution.
Problem:
The client was experiencing a crash when trying to create a normal post in a custom post type, specifically when there were no posts in the custom post type.
Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /wp-content/plugins/sitepress-multilingual-cms/menu/post-menus/wpml-posts-listing-page.class.php:26
Solution:
We recommend adding a conditional check to the relevant file to prevent the crash. Insert the following code to the file
/wp-content/plugins/sitepress-multilingual-cms/menu/post-menus/wpml-posts-listing-page.class
at line 25:
if (empty($wp_query->posts)) return;
This code ensures that if there are no posts, the function will return early and prevent the crash.
Please note that this solution might be outdated or not applicable to your case. If you're still experiencing issues, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket with us.
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.
This topic contains 5 replies, has 3 voices.
Last updated by 9 months, 1 week ago.
Assisted by: Long Nguyen.