Below is a simple shortcode I have so that in an article, I can simply link keywords to tag taxonomy pages in my site.
So if I were to wrap the term Web Service like this [taglink]Web Service[/taglink]
then the function below would replace the space with a - to make Web-Service which would be my tag taxonomy so I could then link to that page.
This...
[taglink]Web Service[/taglink]
Becomes this...
<a href="/tag/web-service" title="Web Service tagged articles">Web Service</a>
The code
function taglink_func($atts, $tag='') {
$formattedTag = str_replace(' ', '-', $tag);
$formattedTag = strtolower($formattedTag);
return '<a href="/tag/' .$formattedTag. '" title="' .$tag. ' tagged articles">' .$tag. '</a>';
}
add_shortcode('taglink', 'taglink_func');
This solkution works fairly well but to improve performance even more, I would like to run this function when I create a new article and when I edit and article, so basicly only when an article is saved, I would like to run this function on any tags in the article and then replace the [taglink]Web Service[/taglink] in the actual database with the result.
So instead of running this on each page view, it will be ran on page save and simply replace the code in the database with the URL link.
Does anyone know how I can do this?