supercapocc
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Cookie Notice & Compliance for GDPR / CCPA] third party cookie integrationNo, you have the wrap the code inside the function..
Forum: Plugins
In reply to: [Ceceppa Multilingua] Adding hreflang tagHello, meanwhile Alessandro will add this feature, i wrote this function to add hreflang inside <head> tag, this work for me, if you want try, put it into functions.php of your theme
function add_hreflang() { global $wpCeceppaML; $current = CMLLanguage::get_default(); $MYurl = cml_get_the_link($current->cml_language_slug); if(cml_is_homepage($MYurl)) { $frontpage_id = get_option('page_on_front'); $homelang = CMLPost::get_language_slug_by_id($frontpage_id); if($homelang != $current->cml_language_slug) { $postid = CMLPost::get_translation($current->cml_language_slug, $frontpage_id); } else $postid = $frontpage_id; } else $postid = cml_get_page_id_by_path($MYurl); $head_link = ""; $alternate = CMLPost::get_translations($postid); if(sizeof($alternate["linked"])) { $original_link = preg_replace( "/\?lang.*/", "", $MYurl); $head_link .= '<link rel="alternate" hreflang="'.CMLLanguage::get_default_slug().'" href="'.$original_link.'" />'; foreach($alternate["linked"] as $key=>$value) { $link = get_permalink($value); $head_link .= '<link rel="alternate" hreflang="'.$key.'" href="'. $wpCeceppaML->convert_url($link, $key ) .'" />'; } } echo $head_link; } add_action('wp_head', 'add_hreflang');
Viewing 2 replies - 1 through 2 (of 2 total)