Resolved
Reported for: WPML Multilingual CMS 3.6.0
Resolved in: 3.6.1
Overview of the issue
When using certain themes, you can get the following fatal error that breaks the display of the page:
Fatal error: Uncaught exception ‘InvalidArgumentException’ with message ‘Argument ID must be numeric and greater than 0’
Workaround
The issue is caused by the themes in question because they are passing arguments with incorrect type (arrays instead of objects) to WordPress filters.
This issue will be resolved in the next release by enforcing the usage of correct type by the variables.
In the meantime, you can patch the code by manually adding the following line to the sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-render.php file, at line 127 (at the top of the function):
$args = (object) $args;
After the patch is applied, the code should look like this:
//...
public function wp_nav_menu_objects_filter( $items, $args ) {
$args = (object) $args;
$menu_id = isset( $args->menu->term_id ) ? $args->menu->term_id : null;
//...
For me not help this patch.
public function wp_nav_menu_objects_filter( $items, $args ) {
$args = (object) $args;
$menu_id = isset( $args->menu->term_id ) ? $args->menu->term_id : null;
$slot = $this->settings->get_menu_settings_from_id( $menu_id );
if( $slot->is_enabled() && ! $this->is_hidden( $slot ) ) {
$lang_items = $this->get_menu_items( $slot );
if ( $lang_items ) {
if ( 'before' === $slot->get( 'position_in_menu' ) ) {
$items = array_merge( $lang_items, $items );
} else {
$items = array_merge( $items, $lang_items );
}
}
}
return $items;
}
Hello @gyorgyF,
You might have another/different problem. Could you please open a ticket on the support forum https://wpml.org/forums/forum/english-support/? Provide your debug information in WPML -> Support -> debug information.
A supporter will take care of your issue and give a dedicated assistance.