Personally I’d use a different approach, because @Shazzad‘s solution seems too much global dependent, and @s_ha_dum‘s needs 2 hooks instead of one.
I’d use get_current_screen
function to get a WP_Screen
object, then I’d look at its property to run (or not) something after the title:
function do_something_after_title() {
$scr = get_current_screen();
if ( ( $scr->base !== 'post' && $scr->base !== 'page' ) || $scr->action === 'add' )
return;
echo '<h2>After title only for post or page edit screen</h2>';
}
add_action( 'edit_form_after_title', 'do_something_after_title' );
Related Posts:
- Keyboard shortcut for updating a page or post?
- Custom function for “Submit for Review” hook
- Getting a 404 error when clicking edit page
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Adding buttons to Add New Post and Add New Page
- Hooking into the post editing screen for an existing page only
- How to dynamically parse and transform post/page content before displaying it?
- Is there a way to know when a page has been updated and do some action only once?
- Stop WordPress Wrapping Images In A “P” Tag
- Determine if page is the Posts Page
- Hook for post and page load
- Get the Current Page Number
- Stop WP from creating “Sample Page” and “Hello World!” post
- Apply the_title() filter in post & page title, but not in menu title
- How to display by default only published posts/pages in the admin area?
- Get current menu_order
- Difference between an archive and a page listing posts
- Delete Associated Media Upon Page Deletion
- The next_posts_link() works only with original $wp_query
- Get content from one page and show it on another page
- How to Check if a Page Exists by URL?
- Customizing HTML Editor Quicktags button to open a dialog for choosing insert options
- Hook that get’s triggered when the author of a post is changed
- Allow user to “edit_others_posts” to save only, not publish
- Connection lost. Saving has been disabled… (Updating Posts/Pages)
- get_children() Not Working with orderby Parameter
- The hook for the AJAX Add to Cart button?
- Get old values for post before saving new ones
- Let private posts stay in status “private” after edit through “editors”
- Execute function when post is published
- Using single.php from plugin folder instead of default template folder
- Post/Page Publish/Update button not clickable once I make an edit
- Strategy for handling hierarchical pages with empty parent content
- Skipping first 3 posts in wp query
- Custom Field in Featured image for A particular post
- How to add a new tab to page editor
- Listen to Post action
- How to display the page title/content in the Posts page?
- How to create WP Editor using javascript
- Callback for wp.autosave.server.triggerSave();
- How can I see a list of pages and post where my custom Gutenberg block is used?
- How to add editor’s name to entry meta byline?
- Restore contents of deleted user
- disable password protected page for logged users
- Action hook ‘wp’ firing twice… why?
- How to change post to page
- RSS for Pages Instead of Posts?
- Display posts by tag on page
- Why do I need to use The Loop on pages (inside page.php etc)?
- What is the difference between “post” and “page” in WordPress?
- Create custom page in WooCommerce
- posts page – different lengths of excerpt
- In what sequence are the hooks fired when a post is “published”?
- WordPress automatic and permanent page
- Restrict access to post if it is currently being edited
- Change padding to text indent in “Increase indent” TinyMCE
- Is there a WordPress equivalent to MediaWiki templates
- Determining Slug Before and After Edit
- Getting an alphabetic post list with two letters onclick on letter
- How can I allow editors to leave comments on posts that have not yet been published?
- Automatically added brs and paragraphs?
- Automatically create pages in a post based on number of words
- Better post meta efficiency?
- Count singular post views automatically
- Static posts page with home.php
- Change WordPress post-state in Admin Area
- Pagination not working on Custom Page Template
- How can I pass $post object to ‘save_post’ add_action?
- Set number of article per number of page
- Pagination for Pages and Posts
- How to change post status from publish to draft using hook in wordpress?
- Is it possible to show a different WP menu when using password protected pages?
- Can I change a post to a page by changing it’s type?
- Overview with latest edited posts and pages
- Filter post before *editing*
- how to show all post in my page-grid.php template page
- eBooks download website, page or post?
- Multiple loops in same page, without duplicate content
- WordPress Delete hook with wp_delete_post function?
- Add a custom option to a page in backend
- Include related posts on a page
- why does HTML Tag not working in Post and Page
- Creating new page with pre-defined parent page
- problem to delete page
- First hook to use current page post id
- Why does `url_to_postid` return 0 when testing `page_for_posts` Page?
- add image map script to post
- Populating a page with content from post custom fields
- Content editor creating blank paragraphs in spaces and creating   in the_excerpt
- Can I hide a specific post from latest posts page?
- Hide add new page button
- Edit menu item title from edit page/post
- Redirect before post page
- How to place HTML below the title of the (custom) post overview
- How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
- $post object is null
- How to show post(excerpt) from specific category on wp page?
- 2nd button row from WP Super Edit or TinyMCE Advanced doesn’t show to 2nd admin
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Is there any WordPress alternative to Book module of Drupal?