I know how to filter the output of the function the_permalink
- it is like this:
add_filter('the_permalink', 'my_the_permalink');
function my_the_permalink($url) {
return 'http://mysite/my-link/';
}
And it works when I use it like: <?PHP the_permalink($id); ?>
, but I wanted to change the link returned by get_permalink($id)
function. And this filter doesn't affect the returned permalink in that case.
I was trying to catch it with:
add_filter('post_link', 'my_get_permalink', 10, 3);
function my_get_permalink($url, $post, $leavename=false) {
return 'http://mysite/my-link/';
}
But this filter isn't fired for the get_permalink()
. So how can I alter the links returned by the get_permalink()
?
get_my_permalink()
and use it instead ofget_permalink()
but I am wondering if I can do this on some higher level.