WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
Non-existent link (4 posts)

  1. Carlos
    Member
    Posted 1 year ago #

    Hi again!

    I have a problem which is similar to what I posted here: http://wordpress.org/support/topic/monthly-archives-2

    The thing now is that I found a '<link' with the same links as in the archives ( non-existent links ). I explored the code and I found the function which is generating it:

    // meta in the html head section
    	function wp_head() {
    		// outputs references to translated pages (if exists) in the html head section
    		foreach ($this->get_languages_list() as $language) {
    			if ($language->slug != $this->curlang->slug && $url = $this->get_translation_url($language))
    				printf("<link hreflang='%s' href='%s' rel='alternate' />\n", esc_attr($language->slug), esc_url($url));
    		}
    	}

    Following the example of the other case, I modified it to be:

    // meta in the html head section
    	function wp_head() {
    		// outputs references to translated pages (if exists) in the html head section
    		foreach ($this->get_languages_list() as $language) {
    			if ($language->slug != $this->curlang->slug && $url = $this->get_translation_url($language))
    				$url = apply_filters('pll_the_language_link', $url, $language->slug, $language->description);
    
    				if( !empty( $url ) )
    					printf("<link hreflang='%s' href='%s' rel='alternate' />\n", esc_attr($language->slug), esc_url($url));
    		}
    	}

    It seems to be working, but I just wanted to make sure by checking with you.

    Please, can you confirm it?

    Thank you!!

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, it makes sense to apply this filter here too. I will add it in the next release.

  3. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    I changed my mind since the two functions wp_head() and pll_the_languages() can have two different links in case someone chooses to force the language switcher to link to the homepage.

    So I created a new filter 'pll_translation_url' which you use the same way (but is fired sooner in the get_translation_url function).

    You can try it with the latest development version (1.1.1.7)
    http://downloads.wordpress.org/plugin/polylang.zip

  4. Carlos
    Member
    Posted 1 year ago #

    Great! Again, thank you so much! =)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic