Fixing the dot problem in polylang

Fixing the dot problem in polylang in wordpress
Such a problem of displaying dots was noticed in the polylang plugin, on the pages of categories or tags, when generating the hreflang attributes of the multilingual version of the site. This attribute is an important component of SEO and data for search engines. Therefore, the correct display of this attribute is important.

The hreflang attribute looks like this:

The hreflang attribute

Such a record gives information to search engines that the multilingual page has an alternative in another language, these pages should be distinguished, indexed under different links and avoid duplicate content.

The polylang problem is noticed if there is a dot in the prefix fields for categories or for tags in the permalink settings:

Настройки постоянных ссылок

And this is what hreflang looks like:

The hreflang attribute

This entry is incorrect.

Let me remind you that a dot is placed in the prefix fields if it is necessary to remove the display of the prefix in the urls for categories or tags.

You can solve this problem by writing a callback function for pll_rel_hreflang_attributes. Insert the following code into functions.php of your theme:

As a result, we get these attributes:

The hreflang attribute

Tested on polylang 3.2.5

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave a comment

Your email address will not be published.