How can I add the dynamic permalink in the post itself? Is there some escape character that's needed?
EXAMPLE: In my post for, say, tomorrow, I want to add something like:
MARY LINKS TO %this_permalink% EVERY DAY.
and have it automatically populate the PHP code. I don't mean in the template footer or other php pages. I want to add it to the text (or HTML) body of the post itself. Thanks! Jeff M
You could use this plugin
http://wordpress.org/extend/plugins/exec-php
to put the template tag within your post.
I did not test this, but it should work :)
<?php
/*
Plugin Name: Add Permalink
Plugin URI: http://www.dagondesign.com
Description: Replaces %this_permalink% with the permalink of the post/page being viewed
Author: Dagon Design
Version: 1.0
Author URI: http://www.dagondesign.com
*/
function add_permalinks($content) {
return str_replace("%this_permalink%", '<a href="' . get_permalink() . '">' . get_permalink() . '</a>', $content);
}
add_filter('the_content', 'add_permalinks');
?>
That's really easy! I had no idea. I'm going to be using that for a few things from now on I think - thank you :).
geekygrrrl
Member
Posted 3 years ago #
I came across this post and am so thankful I found it! Exactly what I was looking for as well! Thanks