Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter rachpape37

    (@rachpape37)

    Sorry the code did not display correctly :/

    this is it:

    <li><a href="https://test.bcnwellwoman.com/en/services/acupuncture/"><?php _e("Acupuncture", "wellnesscenter-child"); ?></a></li>
                <li><a href="https://test.bcnwellwoman.com/en/services/massage/"><?php _e("Massage", "wellnesscenter-child"); ?></a></li>
    Plugin Support Chrystl

    (@chrystl)

    Hi
    You should use the get_permalink and pll_get_post functions.

    Here an example:

    <a href="<?php echo get_permalink( pll_get_post (12) ); ?>"><?php
    if ( 'en_GB' == get_locale() )
        echo 'My text in English';
    else
        echo 'My text in French'; ?>
    </a>

    Thread Starter rachpape37

    (@rachpape37)

    Hi Chrysti!

    Thank you for the reply, where do I place this function? In my theme’s function.php ?

    thanks!

    Plugin Support Chrystl

    (@chrystl)

    In your footer.php.

    Thread Starter rachpape37

    (@rachpape37)

    Hi again,

    I have tried to get it to work, but now the link does not work, could you see where I am incorrect in the below code: ?

    <a href="<?php echo get_permalink( pll_get_post ($Acupuncture) ); ?>">
    <?php
    if ( 'en_US' == get_locale() )
        echo 'Acupuncture';
    else
        echo 'Acupuntura'; ?></a>
    Plugin Support Chrystl

    (@chrystl)

    In pll_get_post, it’s the id of your post which is requires, see the doc.
    So does $Acupuncture is equal to an id?

    Thread Starter rachpape37

    (@rachpape37)

    Hi Chrysti,

    I am sorry, I really do not know php, so I am not sure how to write the id correctly. I would like to use the page title as the id, that is why I wrote Acupuncture, because this is the name of the page.

    Thread Starter rachpape37

    (@rachpape37)

    I also tried this function, but also did not retrieve the page in Spanish:

    <a href="<?php echo esc_url( get_permalink( get_page_by_title( 'Monthly Events' ) ) ); ?>"><?php esc_html_e( 'Monthly Events', 'textdomain' ); ?></a>

    Plugin Support Chrystl

    (@chrystl)

    In fact you need to have the id of your English page, Acupuncture.
    Could you go please edit this page (Pages > All pages > Edit), then you will find in the URL of the id, example: wordpress/site/wp-admin/post.php?page=16&action=edit.
    16 is the id of the page. So for example replace $Acupuncture by 16.

    Thread Starter rachpape37

    (@rachpape37)

    Oh yes, it finally worked! Thank you so much!

    My final solution looked like this :

    a href="<?php echo get_permalink( pll_get_post (6668) ); ?>">
    <?php
    if ( 'en_US' == get_locale() )
        echo 'Acupuncture';
    else
        echo 'Acupuntura'; ?></a>
    Plugin Support Chrystl

    (@chrystl)

    Great! Could you please mark your topic as “resolved”? Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Links in Footer not translating’ is closed to new replies.