• Resolved James Hunt

    (@bonkerz)


    I’ve built a custom template for a client with translations being handled by MultiLang. I’ve got a problem where some hardcoded links (text, buttons) are not changing URLs when I change languages. How should I handle these hardcoded links?

    Is this what wpm_translate_url ($url, $language = ''); is for? If so, how to use it?

    My current code is like this:

    <a href="/contact/" class="btn-outline"><i class="fa fa-chevron-right"></i><?php _e( 'Contact', 'mytheme'); ?></a>

    The /contact/ is the link the needs to change to /ar/contact/

    • This topic was modified 6 years, 8 months ago by James Hunt.
Viewing 3 replies - 1 through 3 (of 3 total)
  • You need to use full post link with domain.
    As example:

    
    <a href="<?php echo wpm_translate_url(get_the_permalink(99));?>" class="btn-outline"><i class="fa fa-chevron-right"></i><?php _e( 'Contact', 'mytheme'); ?></a>
    
    Thread Starter James Hunt

    (@bonkerz)

    OK no problems

    Cheers

    Thread Starter James Hunt

    (@bonkerz)

    It was actually get_permalink not get_the_permalink, ended up doing something like this:

    <a href="<?php echo wpm_translate_url(get_permalink(493)); ?>"><span><?php echo get_the_title(493); ?></span></a>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hardcode links in templates – not changing solution?’ is closed to new replies.