We have just released WPML 4.3.3. Before reporting issues please make sure to update - this version resolves all known issues with the major WPML 4.3 release

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by stefanE-16 1 year ago.

Author Posts
October 14, 2018 at 11:24 am

stefanE-16

I am trying to:
Show posts on mobile.

Link to a page where the issue can be seen:
(I have turned off WPML CMS so that posts can be seen even on mobile.)
hidden link

I expected to see:
Posts on mobile using WP AMP.

Instead, I got:
This error message. I turned WP AMP debug to save error to log and here is the error log message.

Stack trace:
#0 /home/coinnswf/public_html/wp-content/plugins/wp-amp/includes/class-amphtml-no-conflict.php(66): WPML_SEO_HeadLangs->__construct(Object(SitePress))
#1 /home/coinnswf/public_html/wp-includes/class-wp-hook.php(286): AMPHTML_No_Conflict->add_hreflangs(Object(WP))
#2 /home/coinnswf/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#3 /home/coinnswf/public_html/wp-includes/plugin.php(515): WP_Hook->do_action(Array)
#4 /home/coinnswf/public_html/wp-includes/class-wp.php(726): do_action_ref_array('wp', Array)
#5 /home/coinnswf/public_html/wp-includes/functions.php(960): WP->main('')
#6 /home/coinnswf/public_html/wp-blog-h in /home/coinnswf/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/seo/class-wpml-seo-headlangs.php on line 16
[13-Oct-2018 16:23:21 UTC] PHP Notice: Constant ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS already defined in /home/coinnswf/public_html/wp-content/plugins/wp-amp/includes/class-amphtml-no-conflict.php on line 55
[13-Oct-2018 16:23:21 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WPML_SEO_HeadLangs::__construct(), 1 passed in /home/coinnswf/public_html/wp-content/plugins/wp-amp/includes/class-amphtml-no-conflict.php on line 66 and exactly 2 expected in /home/coinnswf/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/seo/class-wpml-seo-headlangs.php:16
Stack trace:
#0 /home/coinnswf/public_html/wp-content/plugins/wp-amp/includes/class-amphtml-no-conflict.php(66): WPML_SEO_HeadLangs->__construct(Object(SitePress))
#1 /home/coinnswf/public_html/wp-includes/class-wp-hook.php(286): AMPHTML_No_Conflict->add_hreflangs(Object(WP))
#2 /home/coinnswf/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#3 /home/coinnswf/public_html/wp-includes/plugin.php(515): WP_Hook->do_action(Array)
#4 /home/coinnswf/public_html/wp-includes/class-wp.php(726): do_action_ref_array('wp', Array)
#5 /home/coinnswf/public_html/wp-includes/functions.php(960): WP->main('')
#6 /home/coinnswf/public_html/wp-blog-h in /home/coinnswf/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/seo/class-wpml-seo-headlangs.php on line 16
[13-Oct-2018 16:23:35 UTC] PHP Notice: Constant ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS already defined in /home/coinnswf/public_html/wp-content/plugins/wp-amp/includes/class-amphtml-no-conflict.php on line 55
[13-Oct-2018 16:23:35 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WPML_SEO_HeadLangs::__construct(), 1 passed in /home/coinnswf/public_html/wp-content/plugins/wp-amp/includes/class-amphtml-no-conflict.php on line 66 and exactly 2 expected in /home/coinnswf/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/seo/class-wpml-seo-headlangs.php:16

NB! Let us know if you need a Duplicator backup.

October 16, 2018 at 7:43 am #2819973

Andrés
Supporter

Languages: English (English ) Spanish (Español ) French (Français )

Timezone: Europe/Paris (GMT+01:00)

Hello there,

Welcome to WPML support forum.

Please apologize for the delay in answering. This is not usual in this forum. While one of my teammates takes care of your case I will provide you with the first debugging steps.

Please try the following:
- Make a full backup of your site.
- Open the following file .../wp-content/plugins/wp-amp/includes/class-amphtml-no-conflict.php, línea 61.
- Change:

	
public function add_hreflangs() {
    global $sitepress;
 
    $settings = $sitepress->get_settings();
    if ( $settings['seo']['head_langs'] AND class_exists( 'WPML_SEO_HeadLangs' ) ) {
        $wpml_seo_headlangs = new WPML_SEO_HeadLangs( $sitepress );
        add_action( 'amphtml_template_head', array ( $wpml_seo_headlangs, 'head_langs' ) );
    }
}

For:

	
public function add_hreflangs() {
    global $sitepress;
 
    $settings = $sitepress->get_settings();
    if ( $settings['seo']['head_langs'] AND class_exists( 'WPML_SEO_HeadLangs' ) ) {
        $wpml_seo_headlangs = new WPML_SEO_HeadLangs( $sitepress, new WPML_Queried_Object_Factory );
        add_action( 'amphtml_template_head', array ( $wpml_seo_headlangs, 'head_langs' ) );
    }
}

Does it work now?

Let us know if it helps.
Andrés

October 30, 2018 at 2:03 pm #2862134

stefanE-16

The code adjustment helped! Thank you very much!
I am guessing you will then pass on the code to the WP-AMP developers so they can get this fixed for an upcoming version of the plugin.