Syndicate content

Polylang messes up my canonical link on my website

I just created a new website and added a few plugins, one of which is Polylang. It generally works okay. Not what I really would like to have, but close enough for a Wordpress website.

Only, it has a horrible side effect:

I destroys the canonical URL which instead of appearing as expected appears with a "%pagename%" variable in it. This is because the module caches the results of a previous call and returns that cahed value instead of recomputing it. There isn't really a way for the filter at that low level to know what version should be returned, so it ends up returning the wrong one.

To fix the problem, I went to the plugin and commented out two lines.

In the file named wp-content/plugins/polylang/include/filters-links.php

Search for a couple of lines that start with "add_filter(". In the offensive version, the original code looks like this:

if ( $this->options['force_lang'] ) {
        add_filter( 'post_link', array( $this, 'post_type_link' ), 20, 2 );
        add_filter( '_get_page_link', array( $this, '_get_page_link' ), 20, 2 );
}

Once ommented out, it looks like this:

if ( $this->options['force_lang'] ) {
        //add_filter( 'post_link', array( $this, 'post_type_link' ), 20, 2 );
        //add_filter( '_get_page_link', array( $this, '_get_page_link' ), 20, 2 );
}

This obviously means the links cannot all be working quite right. But at least my canonical is showing up as expected now.

My Bug Report https://github.com/polylang/polylang/issues/149

Syndicate content

Diverse Realty

Diverse Realty Team

Want a New Home?
Want to Sell Your House?

Call Alex at
+1 (916)
220 6482

Alexis Wilke, Realtor
Salesperson
Lic. # 02024063

Cory Marcus, Broker
Lic. # 01079165

     

Terms of Site Index

Find the page/content you are looking for with our index.