Changing “Add New Post” to a string with unescaped HTML tags cannot be accomplished using only PHP: WordPress core escapes any HTML in the CPT’s label for that text.
Additionally (again, only using PHP), there is no way to remove that block of text: setting the add_new_item
label to blank when registering the CPT results in “Add New” being displayed.
Your best option is to use CSS to hide the core text, and then add your own <h1>
:
add_action( 'edit_form_top', static function () {
if ( empty( $_GET['post'] ) ) {
return;
}
$post_id = absint( $_GET['post'] );
if ( 'wpse416980' !== get_post_type( $post_id ) ) {
return;
}
echo '<style>.wrap h1.wp-heading-inline { display: none; }</style>';
printf(
'<h1>%s<span class="custom-class">%s</span></h1>',
__( 'Custom post title: ', 'custom-plugin' ),
get_the_title( $post_id )
);
} );
Related Posts:
- Customizing subject in comment notification e-mails
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Redirect to another page using contact form 7? [closed]
- How do I add $_SESSION[”] to my wordpress page?
- Save user total active time after login in wordpress [closed]
- How to get the custom field value using SQL query
- Problem with checked box on wp car manager plugin
- Plugin Hook: Get posts
- public custom posts not showing in my wordpress plugin
- How to fetch WordPress Gallery Images to a Custom Post Type?
- execute function after one completed
- How to make multiple admin pages for one plugin?
- Include a php file from another plugin
- How to display results from a data table with an encrypted user id?
- How to add custom function to pluggable.php
- WordPress Post HTML after Posting
- Settings options not showing up on Sub Menu page in WordPress plugin
- How to deactivate my plugin upon deactivation of NextGen
- How to automatically activate users after registration without activation email?
- Creating a plugin that will display text on every page
- Custom Post Type, Custom Columns List
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- How to create repeater field manually, without plugin (ACF Pro)?
- can’t unzip file
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to Add text value in Automatically in this conditions?
- Activation flow of a plugin in a multisite environment
- Checkbox show / hide output result
- Need to edit author permissions | custom taxonomy
- Use a hook or filter, or overwrite this Gamipress function?
- Is it possible to pin a post in second position from top
- Add hook after content without formatting
- i need to make custom cron_schedule with custom interval time as a parameter into a custom payment gateway plugin wordpress
- save_post_product action not firing
- Conditional delete metadata does not works
- Check if theme supports sidebar
- Unexpected add action function in WP plugin
- WordPress Custom Hook with Class method
- How to create admin setting for this small plugin
- Allow a particular user to access a particular plugin?
- admin_notices show after load completed
- Prevent WordPress from sending set-cookie http header
- admin_post hook not firing function inside class
- How to display the category name in the tab and post inside the tab in WordPress?
- Cookie value changes back to previous value after changing
- custom post type plugin error [closed]
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- Change plugin descriptions
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- How to display the custom post related blog by category?
- How use wp_insert_post and add og:custom tags?
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- How to arrange custom posts in the backend/admin by custom taxonomy
- Plugin Development using classes – Public & Private Callbacks
- The Build menu theme is frozen with the wordpress theme
- save_post hook partly firing in update post
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- WordPress hide post from custom post-type on a single page
- Ultimate Members Default Post Layout problem
- The function called on the wp head hook becomes null
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- How can I translate something in my class constructor of my plugin in WordPress?
- custom post type get_posts() function not work
- Create multiple posts when a custom post is created
- Define global variable in theme file and call that variable in plugin file
- Why is my shortcode not working?
- WordPress rewrite rule depend on meta values not ids
- Rename a folder via HTML POST request
- How to change “Read More” text?
- Hooking into the HTML header container
- How to translate to spanish wordpress hardcoded content/files?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- $wpdb->insert not working inside save_post tag
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- update_post_meta is not working for me when I use e.preventDefault for update button
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- working code, not working – Plugin Dev
- Cannot view Custom Post Type no matter what I try
- SimpleXML is not working with xml response from external api
- How to use Datatable with Ajax when creating plugin on WordPress?
- WordPress plugin blog creation
- Problem with wordpress has_action() function
- When/where would want to attach other classes to the base class in a WordPress plugin?
- Offering a freemium plugin (a free version + paid version)
- Using id to show item
- Multiple image selection custom widget
- implement checkbox or toggle switch in plugin code
- 500 Internal server error wp_handle_upload_prefilter
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Change Woo Custom Endpoint Titles from a Plugin
- Create a form and have custom menu display based on user answers?
- Showing how many times is plugin activated or deactivated
- Passing function into add_action always returns the first argument
- Can’t access 3rd party API, code works on local server but not on wordpress
- Generate and send ICS file through WordPress
- Get post content inside plugin class method
- Hook to display element as product on category page
- Is admin section completely customizable in terms of styling?