When you add a filter to post_type_link
, you are telling WordPress to run the hooked function on the result of the get_post_permalink()
function. So any time that function runs, so does yours.
When I tested the filter myself, I only saw a printed message once for each link, but if you have something like this:
if ( get_permalink() ) {
the_permalink();
}
Then you will see a message printed twice. This is because get_permalink()
calls get_post_permalink()
internally, and so does the_permalink()
. Your custom_post_type_link_venue()
function will run each time.
Since post_type_link
is a filter, not an action, it should only return
a value, and not output anything. If your function does produce any output you may get unexpected results, like you are experiencing.