How do I create a "dynamic" link?
-
So, the title is potentially misleading as I’m not sure the term “dynamic link” is appropriate.
I have a website created in wordpress with a navigation bar at the top, which is visible on every page that you visit. The links are “static”, they do not change from page to page. So, for example, you might see mysite.com/aboutus as one of the links in the navigation menu.
I also set up a plugin (qtranslate, but that’s not too important) to change the language by essentially providing a copy of each page in Spanish. So going to mysite.com/aboutus/?lang=es changes it to Spanish. Now as you navigate it adds /?lang=es to each page you visit, so the entire site remains in Spanish as you navigate around.
Here’s the issue, the first time you click the link (located in the navigation bar and visible on every page) it takes you back to the homepage to change the language, because the link is “static”. So clicking on Spanish takes you back to mysite.com/?lang=es. I want to make that link “dynamic” so that it changes relative to the page your viewing. So if you’re viewing the about us page at mysite.com/aboutus and you switch to Spanish it takes you to mysite.com/aboutus/?lang=es and not the home page in Spanish.
As the link is in the navigation bar, the same link appears on every page, so I cannot manually set the link for every page (it would also be very time consuming just because of the number of pages).
So in other words, how can I make the link go to mysite.com/[current page]/?lang=es?
Thank you all.
[on a somewhat related side note, I posted the same question earlier, but the phrasing was rather horrible, and I’m not sure anyone would have gathered what I was trying to ask. As I could not delete or edit, I simply marked it “resolved” and wrote a (hopefully) more understandable question.]
The topic ‘How do I create a "dynamic" link?’ is closed to new replies.