admin管理员组文章数量:1327488
I am working on a website, and I am using Polylang to translate it to a different language. In my code I want to get a page title, and display it. My issue is I cannot get it by ID or page_by_path because its going to display the English version of the page on every language.
For example: I want to display the Contact page title on english Contact and on another language its equivalent translated contact page title.
Is there a way to do that?
The code that I'm using so far:
<?php $page = get_page_by_path( 'contact' ); ?>
<span><?php echo get_the_title( $page ); ?></span>
I am working on a website, and I am using Polylang to translate it to a different language. In my code I want to get a page title, and display it. My issue is I cannot get it by ID or page_by_path because its going to display the English version of the page on every language.
For example: I want to display the Contact page title on english Contact and on another language its equivalent translated contact page title.
Is there a way to do that?
The code that I'm using so far:
<?php $page = get_page_by_path( 'contact' ); ?>
<span><?php echo get_the_title( $page ); ?></span>
Share
Improve this question
asked Aug 10, 2020 at 11:27
Simó TamásSimó Tamás
175 bronze badges
1 Answer
Reset to default 3In polylang you can use the function pll_get_post($postID)
to get the id of the translated page like this:
<?php echo get_the_title(pll_get_post(52)); ?>
I'd be glad if you rate my answer if it was useful.
本文标签: plugin polylangMultilanguage website get the titleon different languages
版权声明:本文标题:plugin polylang - Multilanguage website get the title, on different languages 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742200275a2431783.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论