The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] How do I get only dynamic part of the URL? (2 posts)

  1. lynneness
    Posted 8 years ago #

    I am doing a localization of some site that is using WordPress, and I'd like to have URL listed in page template so that two language enter-links with each other.

    For example, we have:
    http://site_url.com/<dynamic link>
    for English site, and
    http://site_url.com/jp/<dynamic link>
    for Japanese site.

    The website is mostly consist of Pages and not Posts. I cannot use page ID since the main site (English) has different page IDs than Japanese ones. All the pages have parent page + page slug.

    I'm sure there is some syntax to just get the <dynamic links> part, but I just cannot find it.

    Thanks in advance!

    ps. Sadly, language switcher is not an option, since... the site admin doesn't want to use it :S

  2. lynneness
    Posted 8 years ago #

    If anyone's interested, this is what I'm end up inserting into Page Template:


    <p align=right><a href="http://site_url.com/jp
    echo $_SERVER["REQUEST_URI"];

    where current URL is http://site_url.com/dynamic/link/ and output is http://site_url.com/jp/dynamic/link/


    <p align=right><a href="http://site_url.com/
    $str = $_SERVER["REQUEST_URI"];
    $array = explode("/", $str, 3);
    echo $array[2];

    where current URL is http://site_url.com/jp/dynamic/link/ and the output is http://site_url.com/dynamic/link/

    ps. We have two separate WP software installed, one in the root, the other in /jp/ folder.

Topic Closed

This topic has been closed to new replies.

About this Topic