1

How does one apply an action to one particular page within admin?

I've added a bunch of wysiwyg editors to one page ("Home") and now I don't need the main editor. But the function below - of course - removes the editor from all pages:

function remove_editor_from_home_page() {

  remove_post_type_support( 'page', 'editor' );
}

add_action( 'init', 'remove_editor_from_home_page' );

How can I target the Home page within admin by name - "Home" - or by page_id?

This other WPSE answer doesn't want to work for me: Target a certain page within wordpress backend

3
add_action( 'add_meta_boxes_page', 'wpse_57924_remove_editor' );
function wpse_57924_remove_editor( $post )
{
    if ( $post->ID == get_option( 'page_on_front' ) /* or hardcode ID if not front page */ )
        remove_post_type_support( 'page', 'editor' );
}
| improve this answer | |
  • Works great. Hardcoding the page ID # doesn't, though. Also: how did you determine the string 'page_on_front' for the "Home" page? How do I target other pages by name? – markratledge Jul 9 '12 at 18:20
  • page_on_front is the ID for the "static front page" under Settings > Reading. You can use other properties of $post to compare to, like post_name (the slug) or post_title (the title). – TheDeadMedic Jul 9 '12 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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