It’s okay to use it more than once, but not encouraged. However, in your first example, you’re saving the URL to the database. When you do that, or when using the URL in the wp_remote_*
context, or a redirect, or any other non-display context, you should be using esc_url_raw()
instead.
Also note that get_post_meta
will return an array, unless the third argument $single
is set to true. If you’re dealing with a single key-value pair you’ll want:
echo esc_url( get_post_meta( $post_id, 'url', true ) );
Hope that helps!