Plugin Author
Chouby
(@chouby)
Hi!
get_site_url()
is not filtered by Polylang. Please use get_home_url()
instead.
Thread Starter
jlucvz
(@jlucvz)
Thank for get_home_url() but how to change the page :
<?php echo get_home_url() ?>/rechercher
to
<?php echo get_home_url() ?>/search
Maybe this solution work :
<?php echo get_home_url() ?>/<?php _e('rechercher','mytheme') ?>
But i’ll like that be automatical because the page search is the translate of the page rechercher in the BO.
Plugin Author
Chouby
(@chouby)
Sorry I did not pay attention to /search
and /rechercher
First home_url
may be even easier to use that ‘get_home_url’ when having paths.
The correct syntax is:
<?php echo home_url('/search'); ?>
and not
<?php echo get_home_url() ?>/search
So that filters don’t believe that you are echoing the home url
/search
is a reserved url in WordPress (for search results in pretty permalinks). If you want to translate this url, it is far more complex than just translating the link. You will have to manage rewrite rules too. Currently, Polylang does not manage this.
Thread Starter
jlucvz
(@jlucvz)
Tnahk you,
I understand i’ll used
<?php echo home_url('/rechercher'); ?>
rechercher in the BO is the french page and i made annother page who it’s the translate of rechercher the name is search-en
then when i’m in french language my link is like this :
<?php echo home_url('/rechercher'); ?>
and it’s appear like this :
http://www.mywebsite/rechercher
and when i m on the englsh language my link ‘ll be
<?php echo home_url('/search-en'); ?>
and it’s appear like this :
http://www.mywebsite/en/search-en
How to have dynamical the good link when i’m in the language english, change automatical rechercher to search-en
Its hard to explain…
Plugin Author
Chouby
(@chouby)
If I well understand, you are not trying to translate the url of the search page defined by WordPress but the url of a page that you created in your admin.
I am sorry but that’s another function 😉
<?php
$id = 1; // replace 1 by your page id in one language
$tr_id = pll_get_post($id); // translate the post in the current language
echo get_page_link($tr_id); // displays the link
?>
Thread Starter
jlucvz
(@jlucvz)
Thank you very much Chouby, merci en Français !!
It’s that you find my problem !
You have found mine too !
Tx Chouby