Working with the php to the current url in WordPress


Today i had several problems with Qtranslate, who simply doesn’t want to translate the static home pages (still don’t know why)… so I started using transposh, which is quite good for how simple it is.

Thing is that the static home page I made, doesn’t have any widget area defined outside the box, so I can’t just add the Transposh widget (I could, but i just need some cute flags that it doesn’t bring either), and I need those flags to point the translation, not just pointing to the home url, but translating the current url where the user is. I know this is a simple fix, but since I had to google it and my blog is my post-it, here is the way to do it. The PHP code you need to add is this:

<?php $url = content_url(); ?>?lang=es”>

This tag should be add before the code you want to add at the end of each url, so, in my case, ended up being something like this:

<a href=”<?php $url = content_url(); ?&gt?lang=es”><img src=”<?php bloginfo(‘template_directory’); ?>/images/Spanish-flag-small.gif”></a>

With this simple code, wordpress will know that it has to use the current url and not the home page one, adding the ?lang=es at the end. You can see that this is an easy fix, and since i add it at the home.php file, I have nothing else to do.

Help tatica and donate with paypal!

Previous Post
How to build Online presentations: Services review
Next Post
[:es]Micro-Charla de Fotografía con Software Libre


Leave a Reply

15 49.0138 8.38624 1 0 4000 1 300 0