Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14611 reviews 1734 hosting providers

Questions & Answers

WP shortcut for post page

Dec 12, 2012 by SunFun
Hi..

My WordPress blog post has a keyword that is linked to tag an archive page. I need to add a tag page link manually, I want to make a shortcode for post page, so that it would directly link back to the tag archive page in the keyword. So for example if I have [Anything] or [tag]Anything[/tag] or [Tag=Anything] then ‘Anything’ text will link to the ‘Anything’ tag archive page.
I would really appreciate any help in this
Many thanks

1 Answer

0 votes
Dec 12, 2012 by expert
Try this code
add_shortcode('tag_link','your_tag_link');
function your_tag_link($atts,$content) {
$url = home_url('/');
   $yourtarget = your_title_with_dashes($yourcontent);
   $link ="<a href='{$url}tag/$yourtarget'>$yourcontent</a>";

   return $link;
}