Strip hashtag off permalink with php

echo get_permalink($post);, or the_permalink() in the Loop context, will give you the canonical URL for the post, without the trailing hashtag part– technically the ‘fragment’.

You could also use PHP’s parse_url to break the URL apart if *_permalink functions don’t work for you for some reason, or even PHP’s strpos and substr for a really homegrown solution.