I want to add image link on wordpress site which redirect the user to the another page of same url but with different prefix. for example page url is mydomain/post1234 when user click the image on this page it redirect the user to the url mydomain/md/post1234
The following code print the current page url on every post page on site but i want to add "md" prefix in the url
<a href="<?php
$Path=$_SERVER['REQUEST_URI'];
$URI=''.$Path;
?>"><img src="<?php bloginfo('template_url'); ?>/images/sgxx.png">Click Here</a>
Pls suggest the correct code to do this.
I want to add image link on wordpress site which redirect the user to the another page of same url but with different prefix. for example page url is mydomain/post1234 when user click the image on this page it redirect the user to the url mydomain/md/post1234
The following code print the current page url on every post page on site but i want to add "md" prefix in the url
<a href="<?php
$Path=$_SERVER['REQUEST_URI'];
$URI='http://www.example'.$Path;
?>"><img src="<?php bloginfo('template_url'); ?>/images/sgxx.png">Click Here</a>
Pls suggest the correct code to do this.
Share Improve this question edited Jul 14, 2015 at 15:53 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Jul 14, 2015 at 15:00 Harendra SinghHarendra Singh 213 bronze badges 1- Both of questions are related to permalinks structure. I don't want to change permalinks. I want to add image link on header of all pages which redirect the user of current page url but with prefix like current page url : example/post1234 redirect page url: example/md/post1234 – Harendra Singh Commented Jul 14, 2015 at 16:00
1 Answer
Reset to default 1Based on this question about retrieving Wordpress post slug, you could put together a link like the following:
<a href="http://www.example/md/<?php global $post; echo $post->post_name; ?>">link text</a>
Whether that goes to a functioning page or not, I don't know. It seems like you may want to change rewrite rules in the functions but I'm not sure from what you've said.
By the way, you may want to read why links that only say 'Click here' are bad practice for SEO and accessibility.