最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Get the ID of the default language equivalent page in Polylang

programmeradmin4浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

How can I get the ID of the default language equivalent for whatever page I’m currently on?

For example, I’m on abc/es/mypage, I want to get the ID of abc/mypage.

I tried setting up the variable this way:

$englishID = get_the_id(pll_default_language());

But this just grabs the ID of the page I’m currently on, not the English equivalent. Any ideas?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

How can I get the ID of the default language equivalent for whatever page I’m currently on?

For example, I’m on abc/es/mypage, I want to get the ID of abc/mypage.

I tried setting up the variable this way:

$englishID = get_the_id(pll_default_language());

But this just grabs the ID of the page I’m currently on, not the English equivalent. Any ideas?

Share Improve this question edited May 4, 2018 at 0:59 Johansson 15.4k11 gold badges43 silver badges79 bronze badges asked May 2, 2018 at 23:27 website walruswebsite walrus 1191 gold badge1 silver badge9 bronze badges 5
  • maybe it is a good time to read what is on and off topic here ;) – Mark Kaplun Commented May 3, 2018 at 5:22
  • 1 Where do I read that? There is even a tag for polylang-plugin, so not sure how this is off-topic – website walrus Commented May 3, 2018 at 20:09
  • wordpress.stackexchange/help – Mark Kaplun Commented May 4, 2018 at 0:55
  • 2 There are 50 active Q's with tag plugin-polylang on this forum right now, and they are certainly not being downvoted. If I'm not supposed to talk about a plugin, why is there a tag for it? – website walrus Commented May 4, 2018 at 1:00
  • StackExchange at its best. Let's not talk about solutions but rather talk about rules what not to post but then, probably for the sake of search engine optimization, inconsequential still keep that seemingly inappropriate off-topic content and even keep the dumbass comments which couldn't be more off-topic at all. – Ingo Steinke Commented Jul 18, 2023 at 16:21
Add a comment  | 

2 Answers 2

Reset to default 4

you can retrieve this identifier with that code :

$defaultLanguage = pll_default_language();

$translations = pll_get_post_translations($post_ID);

$id = $translations[$defaultLanguage];
$post_id = pll_get_post( get_the_ID(), pll_default_language() );

Got this from the plugin author, works great!

发布评论

评论列表(0)

  1. 暂无评论