Skip Navigation

Resolved by author

Reported for: WPML Multilingual CMS 4.5.14

Resolved in: Astra 3.9.4

Topic Tags: Compatibility

Overview of the issue

Astra theme allows you to enable Custom Layouts from its options page. However, with the with its latest 3.9.3 release, any script added in the header or footer does not get loaded when using that feature.

Workaround

There are two workarounds you can try. Before proceeding with either, be sure to make a full backup.

Workaround 1

  1. Open /wp-content/plugins/astra-addon/classes/modules/target-rule/class-astra-target-rules-fields.php. file
  2. Look for line 1306.
  3. Replace:
    if ( class_exists( 'SitePress' ) ) {
        global $sitepress;
        $check_wpml                     = true;
        $current_language               = $sitepress->get_current_language();
        $wpml_translate_query           = "INNER JOIN {$wpdb->prefix}icl_translations as icl ON pm.post_id = icl.element_id";
        $wpml_translate_query_condition = "AND icl.language_code = '{$current_language}'";
    }
    

    With:

    if ( class_exists( 'SitePress' ) ) {
    	global $sitepress;
    	$cpt_translation_mode = apply_filters( 'wpml_sub_setting', false, 'custom_posts_sync_option', 'astra-advanced-hook' );
    
    	if ( $cpt_translation_mode != false ) {
    		$check_wpml                     = true;
    		$current_language               = $sitepress->get_current_language();
    		$wpml_translate_query           = "INNER JOIN {$wpdb->prefix}icl_translations as icl ON pm.post_id = icl.element_id";
    		$wpml_translate_query_condition = "AND icl.language_code = '{$current_language}'";
    	}	
    }
    

Workaround 2

  1. Go to WPMLSettingsPost Type Translation.
  2. Switch the astra-advanced-hook post type to Translatable – use translation if available or fallback to default languageand Save.
  3. Switch back to Not Translatable and Save.

7 Responses to “Astra Pro 3.9.3 - Enabling Custom Layouts blocks loading scripts added in the header or footer”

  1. Thank you for posting this, maybe you should post the easy method at the bottom of the page first? That worked for me.

    Please contact Astra to try to make WPML and Astra more compatible. This is the second time in a month the website has broken due to Astra-WPML compatibility, and it’s costing the client money running Google Ads.

    • Hello Craig,
      We totally understand your concern. We are already in contact with the author and working together to solve this issue.
      Thank you for your understanding.

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>