Reputation: 281
I am running a function whenever a Post is Updated by using add_action('save_post', 'transcription');
I am trying to have the function also run whenever the Edit Post is loaded (before it is Updated or Saved), however when I add:
add_action('post.php', 'transcription');
Nothing Happens.
Any ideas?
Upvotes: 2
Views: 3815
Reputation: 281
Come to find out that when you do an add-action on load-post.php (the correct action for when you want to edit the individual post), it does not pass the post_id. Since my transcription module was dependent on getting the post ID, it was as simple as run $_GET['post'] and assigning it to the post_id variable transcription required
add_action( 'load-post.php', 'transcription' );
function transcription($post_id) {
//Transcription Status 0 = Not Transcribed but uploaded, 1=Submitted for Transcription, 2=Transcribed 3=Transcribed and Addd to Post
$post_id = $_GET[ 'post' ];
//Do whatever with transcription
}
This turns out to be the solution.
Upvotes: 1
Reputation: 557
Try this one:
add_action( 'load-edit.php', 'post_listing_page' );
function post_listing_page() {
//this is the wp-admin edit.php post listing page!
}
in your case:
add_action( 'load-edit.php', 'transcription' );
Reference: https://codex.wordpress.org/Plugin_API/Action_Reference/load-(page)
Upvotes: 3