get the permalink error

You need to remove the $leavename = portion out. That’s the parameter reference.

So your code should be:

echo get_the_permalink($post, true);

tech