post_link
is a filter applied to the permalink URL for a post prior to returning the processed url by the function get_permalink.
This filter only applies to posts with post_type of 'post'. For that filter which applies to custom post type look post_type_link
Append the query string for posts to permalink URLs (uses add_query_arg):
function append_query_string( $url, $post, $leavename=false ) {
if ( $post->post_type == 'post' ) {
$url = add_query_arg( 'foo', 'bar', $url );
}
return $url;
}
add_filter( 'post_link', 'append_query_string', 10, 3 );
This filter is applied by: