Skip to content

Instantly share code, notes, and snippets.

@germanny
Created March 4, 2014 20:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save germanny/9355517 to your computer and use it in GitHub Desktop.
Save germanny/9355517 to your computer and use it in GitHub Desktop.
get page parent in wp-admin
<?php
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
$parents = get_post_ancestors( $post_id );
$id = ($parents) ? $parents[count($parents)-1]: $post_id;
$parent = get_page( $id );
if ( get_id_by_page_name('states') == $parent->ID ) {
// do stuff
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment