Question

Assuming I know the image attachment ID, how can I get the post permalink to which is attached (if any) ?

Was it helpful?

Solution

Roughly this:

$parent = get_post_field( 'post_parent', $id);
$link = get_permalink($parent);
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top