The post_type_link
hooks gets called for all links to custom post types, you are responsible for checking the link type. Remember to use the passed $post
object (not post ID), otherwise you check the current global $post
variable, which may not be the post for which you are creating a link now. So the code you added in your comment is almost correct, I would write it like this:
function cpt1_permalink( $post_link, $post, $leavename )
{
// Yoda condition to be safe
// http://stackoverflow.com/questions/2349378/new-programming-jargon-you-coined/2430307#2430307
if ( 'cpt1name' != $post->post_type ) {
return $post_link;
}
// Rest of your code
}