• in frontend-links.php I need to alter the hreflang before output.

    Would you mind adding a filter hook just before you output?

    // ouptputs the section only if there are translations ($urls always contains self link)
    		if (!empty($urls) && count($urls) > 1) {
    			foreach ($urls as $lang => $url)
    				$lang = apply_filters('link_alt_hreflang', $lang);
    				printf('<link rel="alternate" href="%s" hreflang="%s" />'."\n", esc_url($url), esc_attr($lang));
    		}

    https://www.ads-software.com/plugins/polylang/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    You can remove what’s done by Polylang and add your own

    add_action('pll_language_defined', 'pll_remove_hreflang', 20); // after Polylang
    function pll_remove_hreflang() {
      remove_action('wp_head', array($GLOBALS['polylang'], 'wp_head'));
    }

    not tested but it should work

    Hello Chouby,

    I have tried the code you included above but it does not seem to remove the hreflang tags in the wp_header. I still am seeing the hreflang included in my front page.

    Any ideas why this is?

    Thanks!

    Plugin Author Chouby

    (@chouby)

    Hi!

    This is quite an old topic. Things have changed. Try:

    add_action('pll_language_defined', 'pll_remove_hreflang', 20); // after Polylang
    function pll_remove_hreflang() {
      remove_action('wp_head', array(PLL()->filters_links, 'wp_head'));
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add a hook for hreflang?’ is closed to new replies.