Skip to content

Instantly share code, notes, and snippets.

@grok
Created April 30, 2014 03:35
Show Gist options
  • Select an option

  • Save grok/6916656001ae5206ff7e to your computer and use it in GitHub Desktop.

Select an option

Save grok/6916656001ae5206ff7e to your computer and use it in GitHub Desktop.
This is a really lame way to get the WordPress Post ID when on the administration screen.
<?php
// ...
// This should NOT be this difficult ... but at the moment it's what we have.
private function _get_admin_post_id()
{
return absint(isset($_GET['post']) ? $_GET['post'] : (isset($_POST['post_ID']) ? $_POST['post_ID'] : 0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment