Get the post attached to a image attachment
-
16-10-2019 - |
Question
Assuming I know the image attachment ID, how can I get the post permalink to which is attached (if any) ?
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