admin管理员组文章数量:1313777
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.
本文标签: phpAdd prefix to link url
版权声明:本文标题:php - Add prefix to link url 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741886908a2403074.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论