the content_save_pre filter. It checks the post type of the current post and ensures that the content field is not empty. If the content field is empty, the function calls wp_die() to display an error message and stop the post from being saved.
Note: Make sure to replace “custom_post_type” with the actual name of your custom post type. Also, you can modify the error message to fit your needs.
add_filter( 'content_save_pre', 'validate_custom_post_type_content' );
function validate_custom_post_type_content( $content ) {
global $post;
if ( 'custom_post_type' === $post->post_type && empty( $content ) ) {
wp_die( __( 'The content field is required for this custom post type. Please enter some content and try again.' ) );
}
return $content;
}
Related Posts:
- How to load a new template page according to a particular URL?
- Should I use RIPS tool to test my themes and plugins?
- How to Build a Movie Library in WordPress 3.x
- Workflow and best practice for documentation [closed]
- How to get current post user id
- Redirect to another page using contact form 7? [closed]
- How do I combine a theme with a plugin
- How to write “alt” tag in image for wordpress code?
- Don’t load the theme for a page FROM a plugin EDITED
- Extending a theme: build new features as plugin or core modules?
- How do you create a re-useable HTML fragment in wordpress
- How to override any plugin file in the child theme
- when i activate my WordPress plugin cannot see customizer options or preview
- how to add custom css at top above all css file for specific url
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- Breadcrumb is not generating the correct post page url
- Site is setup statically – how to make it content managable?
- How to escape html code?
- Tips for using WordPress as a CMS? [closed]
- Custom Post Type Templates from Plugin Folder?
- Custom media upload content for inserting custom post shortcode
- How to Remove Certain Screen Options and Meta Boxes from add/edit post type?
- Function to activate WordPress theme inside a plugin
- Which functions in theme or plugin load first
- How to make my plugin theme-independent?
- Updating post meta for custom post types
- remove custom taxonomy metabox form custom post type
- Custom Post Type Statuses
- Autoload via composer in plugin interference
- Is there a quick way to inject i18n domain into theme/plugin files?
- Get image URL from media library in input
- Way to hook into a sidebar call to replace it with a custom sidebar
- Translating plugin inside the theme [closed]
- Include Max mega menu Plugin into theme
- How to integrate plugin in WordPress theme
- add_action in functions.php, do_action in plugin?
- wordpress theme backend admin only
- How does WP handle multiple matching rewrite rules?
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- Different UI in WordPress
- The problem with WordPress Importer
- Is it possible to create Custom Post plug-in?
- Display post lists in 2nd paragraph
- Making a Template for a CPT created by a plugin
- Plugin-generated pages use Not Found or Pages Archive templates?
- Is there any kind of theme on WordPress to sell my own movies?
- Classified ad website : which solutions to use? [closed]
- Homemade plugin while using Themify Ultra
- Finding the URL to be used to check if plugin is installed with a theme
- How can I position ShareThis buttons manually when using the plug-in? [closed]
- Unable to delete custom post types, confusion around capabilities
- How to use get_template part in the plugin?
- Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?
- Shortcode Attributes to Return different $_POST
- How to use the CSS of the WordPress core in the development of my administration page?
- I receive taxonomy id
- Include Minit plugin in theme [closed]
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- Plugin generated unexpected output – No PHP errors
- Remember the Meta Value With Radio Buttons
- display unique post per category
- Custom Post Type template for homepage
- Yoast SEO Plug In and my Theme duplicating code. Need some feedback on what to do? [closed]
- Custom Post Type, Custom Columns List
- Seperate plugin and theme files
- Scrape key check failed. Please try again
- Check if theme supports sidebar
- submit two file input fields in the same form
- custom post type plugin error [closed]
- How to display the custom post related blog by category?
- Problem with checked box on wp car manager plugin
- Rename a folder via HTML POST request
- How to get a post views count using ‘WordPress popular posts’ plugin
- $wpdb->insert not working inside save_post tag
- Cannot view Custom Post Type no matter what I try
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- How to prevent redoing get_posts queries and make results available to other scripts?
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- Remove action added in plugin class from theme
- Can you develop themes and plugins while using the hosting services BlueHost? [closed]
- How can I add a custom checkbox / radio button on the admin theme options to display a CSS or other?
- Input gets deleted/overwritten after changing to different Admin Menu
- Creating themes using the one Plugin (Toolkit)
- How to add jquery to my custom post type wp plugin
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- get_option include in my adsense
- Is an Office a custom post type [closed]
- How can I make a website with dynamic features with wordpress?
- How to create post comparison in wordpress
- How to add image for custom taxonomy
- Javascript as Jquery Function Call?
- Integrating WordPress Content into a jQuery Slider
- manage_{taxonomy}_custom_column not working
- add_meta_box showing blank screen in my page
- How to create an Info Box on WordPress [closed]
- How to access the page without registering in wordpress
- CPT template is not being automatically used single post pages
- What are Seeds? [closed]
- How to provide page_template path in custom plugin using WordPress