• freemp

    (@freemp)


    Since on my website, the static home page differs from the language taxonomy URL (<home-url>/<language-slug>/), I had to apply some little changes to the frontend-links.php file in order to get correct alternate links in the head section.

    --- frontend/frontend-links.php	Wed Mar 25 09:28:47 2015
    +++ frontend/frontend-links.php	Sun Apr 05 18:08:25 2015
    @@ -392,8 +392,11 @@
     				$url = $this->get_archive_url($language);
     		}
    
    -		elseif (is_home() || is_tax('language') )
    +		elseif ( is_home() )
     			$url = $this->get_home_url($language);
    +
    +		elseif ( is_tax( 'language' ) )
    +			$url = esc_url( home_url( $language->slug . '/' ) );
    
     		$translation_url = apply_filters('pll_translation_url', (isset($url) && !is_wp_error($url) ? $url : null), $language->slug);
     		$this->cache->set('translation_url:' . $language->slug, $translation_url);

    https://wordpress.org/plugins/polylang/

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

    (@chouby)

    Hi!

    I suggest that you use a ‘page for posts’ to display your latest posts.

    Thread Starter freemp

    (@freemp)

    I am using a page for posts, but alternate links are wrong anyway. However, with the patch above everything works as expected. I just thought it might be interesting for others as well…

    Plugin Author Chouby

    (@chouby)

    Sorry I don’t understand. If you have a static front page and a page for posts in all your languages, Polylang should not create links to yoursite.com/en/.

    Thread Starter freemp

    (@freemp)

    Well, all I can say is that it obviously does create that link and it points to the page for posts. I realized, when Google Webmaster tools showed “missing back-links” for these pages. When I checked that, I found that the real reason were “alternate” links section pointing to the static front page instead of the page for posts.

    Plugin Author Chouby

    (@chouby)

    My intention is that there is no link to yoursite.com/en if you did not choose it as home page and you use a page for posts. Could you provide a link to check in which circumstances it appears.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Incorrect alternate links in head with static front page’ is closed to new replies.