php - Add prefix to link url in wordpress -


i want add image link on wordpress site redirect user page of same url different prefix. example page url mydomain.com/post1234 when user click image on page redirect user url mydomain.com/md/post1234

the following code print current page url on every post page on site want add "md" prefix in url

<a href="<?php $path=$_server['request_uri']; $uri='http://www.example.com'.$path; ?>"><img src="<?php bloginfo('template_url'); ?>/images/sgxx.png">click here</a> 

pls suggest correct code this.

try this:

<?php     $domain = get_site_url(); //you can use or either "http://".$_server[http_host];     $path = $_server[request_uri];     $prefix = "/md"; ?> <a href="<?= $domain.$prefix.$path ?>">link</a> 

for more info $_server, check link below: http://php.net/manual/en/reserved.variables.server.php


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -