WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know there are a lot of hooks in WP for altering a posts content (and other fields) before the post is written to the DB upon saving; but what I am interested in doing is running my custom filter before the post is loaded for editing. So basically when my custom post type is loaded by /wp-admin/post.php?post=##&action=edit, I would like to run my filter on it before the content is displayed in the WYSIWYG editor. Is that possible or no?

share|improve this question
up vote 3 down vote accepted

You can use the the_editor_content filter:

function wpa_editor_content( $content ) {
    global $post;
    return "this post's id is $post->ID " . $content;
}
add_filter( 'the_editor_content', 'wpa_editor_content' );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.