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: , 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()?

Read more here: How to filter to output of the get_permalink() function


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: