Using WordPress ‘edit_form_after_editor’ PHP action

The edit_form_after_editor WordPress PHP action fires after the content editor in the post editing screen.

Usage

add_action('edit_form_after_editor', 'your_custom_function_name');
function your_custom_function_name($post) {
  // your custom code here

  return $post;
}

Parameters

  • $post (WP_Post) – The post object that is being edited.

More information

See WordPress Developer Resources: edit_form_after_editor

Examples

Display a custom meta box after the editor

This example adds a custom meta box under the content editor for a post.

add_action('edit_form_after_editor', 'display_custom_meta_box');
function display_custom_meta_box($post) {
  echo '<div id="custom-meta-box" class="postbox">';
  echo '<h2>Custom Meta Box</h2>';
  echo '<div class="inside">';
  // your custom code here
  echo '</div></div>';
}

Add a custom message after the content editor

This example displays a custom message under the content editor.

add_action('edit_form_after_editor', 'add_custom_message');
function add_custom_message($post) {
  echo '<p><strong>Note:</strong> Please double-check your content before publishing.</p>';
}

Show word count after the content editor

This example shows the current word count of the post content.

add_action('edit_form_after_editor', 'display_word_count');
function display_word_count($post) {
  $word_count = str_word_count($post->post_content);
  echo '<p>Word count: ' . $word_count . '</p>';
}

Display post format specific instructions

This example displays instructions related to the current post format after the content editor.

add_action('edit_form_after_editor', 'post_format_instructions');
function post_format_instructions($post) {
  $post_format = get_post_format($post->ID);
  if ($post_format == 'video') {
    echo '<p><strong>Video Format:</strong> Please include a video URL or embed code in the content.</p>';
  } elseif ($post_format == 'gallery') {
    echo '<p><strong>Gallery Format:</strong> Please add a gallery shortcode to the content.</p>';
  }
}

Display custom fields data

This example retrieves and displays the custom field value for a post after the content editor.

add_action('edit_form_after_editor', 'display_custom_field_data');
function display_custom_field_data($post) {
  $custom_data = get_post_meta($post->ID, 'your_custom_field_key', true);
  echo '<p>Custom Field Data: ' . esc_html($custom_data) . '</p>';
}