Viewing 1 replies (of 1 total)
  • Thread Starter BSG21

    (@bsg21)

    This code will do it:

    global $wp_query;
     $attachment_page_id = $wp_query->post->ID;
     $parent_post = get_post($attachment_page_id);
     $parent_post_id = $parent_post->post_parent;
    
     $parent_post_permalink = get_permalink($parent_post_id);
Viewing 1 replies (of 1 total)
  • The topic ‘Getting Parent Post Outside of Loop’ is closed to new replies.