Jetpack: Related Posts: conflict with Polylang

Created on 18 May 2017  Â·  24Comments  Â·  Source: Automattic/jetpack

Steps to reproduce the issue

  1. Install Jetpack and activate Related Posts.
  2. Install and activate the Polylang plugin.
  3. Go to Languages, create a new default language, and assign all your posts to that language.
  4. Create an additional language, no need to assign any posts to that one yet.
  5. Visit one of your posts => Related Posts are gone.

This used to work in the past, but doesn't anymore.

The problem seems to be linked to a specific function used in Polylang to make sure Related Posts match the language used in the original post:

Commenting this out solves the issue.

This function was added to Polylang after discussion with us, and worked at the time. See p3py7Y-C7-p2 and 2487669-t for earlier discussions about this.

cc @gibrown since you worked on the original request. Did ElasticSearch's syntax for languages change, maybe?

Related: #3280

Related Posts [Pri] Normal [Type] Bug [Type] Happiness Request

Most helpful comment

I have created a pull request that fixes this in polylang:

https://github.com/polylang/polylang/pull/135

you can see the results of these changes on this post from my test site:

http://blog.parks-place.com/en/the-iron-fist/

All 24 comments

cc @Chouby, Polylang author; just in case you receive reports about issues with Related Posts on your end!

Ya, we've been working on a fix for this issue for a little while. Root problem is that we've hit some scaling issues with Elasticsearch and the total number of fields you can have. Storing custom taxonomies as taxonomy.*.slug means we've started to hit some limits at 200k+ fields.

For some subset of sites, they are probably working ok, but some do not currently have all of their custom taxonomy information in the index.

We have a more permanent fix, but it will probably be a few weeks before we can get it fully deployed because we have to rebuild the entire index which takes at least a two weeks (and probably longer due to some other issues). We'll see if we can get a work around in place for this particular user/plugin.

I was able to reproduce using the steps above and I see that this is the filter that is used by polylang:

{
  "size":3,
  "filter":{
    "and":[
      {
        "term": {
          "post_type":"post"
        }
      },
     {
       "term": {
         "taxonomy.language.slug":"english"
       }
     }
   ]
  }
}

But this is what is indexed for the language taxonomy:

"language": [
  {
    "name": "English",
    "slug": "en",
    "term_id": "3"
  }
]

So, the reason that related posts aren't coming back is because it's searching for the slug english instead of the en

I have created a pull request that fixes this in polylang:

https://github.com/polylang/polylang/pull/135

you can see the results of these changes on this post from my test site:

http://blog.parks-place.com/en/the-iron-fist/

@jeherve Thanks for pinging me.

@gibrown So if I well understand: Up to now, you stored only the term name on the Jetpack server and thus could not take into account a customized term slug (such as en for English). And starting from now, you are storing the term slug as it is in the WordPress site. Am I right? Do we need a specific Jetpack version for this to work or did this all happen only on the Jetpack server?

@stevekaeser Thanks for the PR :)

The user in 975211-zen reported that Related Posts do not show when Polylang is active. The issue occurs with posts in both English and German, so it does not seem to be limited to a specific language. Related Posts show in the Customizer for both languages, but do not appear on the live site.

@jeherve does this sound like the same issue you originally reported above?

Yes, although we've made some more changes to Jetpack in 5.8 that may fix their problem. I would recommend updating to the most recent version of Jetpack, scheduling a full sync, and waiting for 12 hours for the cache to clear.

Related: 1598-gh-jpop-issues

a user came back to report polylang updated and the issue resurfaced in 1223575-zen I went ahead and commented out the same line mentioned in 1598-GH to get them working again.

We have another user with this issue in 1240776-zen. The code that was commented out before is no longer there. Can @gibrown or @stevekaeser take a look? They were also using acf-options-for-polylang-master and Loco Translate but have since disabled them and it didn't fix the issue.

Do we have any news about this bug? I still have a user on 1240776-zen waiting for an update. I'm going to follow up with them meanwhile.

This issue has been marked as stale. This happened because:

  • It has been inactive in the past 6 months.
  • It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`.

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

We have another case of this here 2304697-zen. It also looks like this was never addressed in 1240776-zen above.

Any updates on whether this will be worked on @jeherve, or are we just accepting problem cases as known conflicts?

No updates so far, but we'll update this issue when we do start to work on this.

In case it can help locating the problem's cause, the secondary language will show the related posts correctly but with the "RELATED" header that would correspond to the primary language, with no way of changing it in Polylang's "Strings translations".

@ICEknigh7 You may be able to use the jetpack_relatedposts_filter_headline filter to customize the Related headline that's displayed above related posts.

You can find out more about how to use it here:
https://developer.jetpack.com/hooks/jetpack_relatedposts_filter_headline/

@Chouby Do you think it would make sense to add an option in Polylang so folks can enter different Related Posts Headline values for each language?

This issue has been marked as stale. This happened because:

  • It has been inactive in the past 6 months.
  • It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`.

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

@Chouby Please take a look again at this issue, thanks! This issue is still here... https://wordpress.org/support/topic/only-old-posts-show-up-in-related-posts/

Another in 3067138-zen

This issue has been marked as stale. This happened because:

  • It has been inactive in the past 6 months.
  • It hasn’t been labeled `[Pri] Blocker`, `[Pri] High`.

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

The author of Polylang says: “ The related posts are evaluated on the Jetpack servers. If something is changed in the way it is done, there is no way for us to know, and no way for us to know what to do.” https://github.com/polylang/polylang/issues/594#issuecomment-755214366

So please, take a look again, or communicate with each other, thanks very much!

@physixfan This issue is referring to related posts matching the wrong language, as set in Polylang. In the forum thread you mentioned above, you seem to be experiencing a different issue with all your new posts missing Related Posts. Is that correct? Is this happening regardless of the language of the post on your site?

If you have more details, do you think you could contact us via this contact form, so we can look into this further with you? It could be that your problem is different from the one we're discussing on this GitHub issue.

Thank you.

@physixfan This issue is referring to related posts matching the wrong language, as set in Polylang. In the forum thread you mentioned above, you seem to be experiencing a different issue with all your new posts missing Related Posts. Is that correct? Is this happening regardless of the language of the post on your site?

If you have more details, do you think you could contact us via this contact form, so we can look into this further with you? It could be that your problem is different from the one we're discussing on this GitHub issue.

Thank you.

Yes, you are right, maybe our problem is different from this Github issue. I can't remember why I was redirected here. Anyway I've contacted you guys via contact form.

Was this page helpful?
0 / 5 - 0 ratings