Link to the parent post in attachment page
Here’s one way within the main loop on the attachment’s page: First we get the parent ID from the current attachment’s post: $parent_id = get_post_field( ‘post_parent’ ); Then we check if it’s non-zero and print the link to the parent: if ( $parent_id ) { printf( ‘<a href=”https://wordpress.stackexchange.com/questions/312468/%1$s”>%2$s</a>’, esc_url( get_permalink( $parent_id ) ), esc_html__( ‘Go … Read more