Assuming you’re using gutenberg you need to use javascript to do this. Here’s the steps I would take. In your child theme you’ll need to add some code.
-
Add a new directory “js”.
-
In that directory add a new file called “alerts.js”
-
In that file add this code: (this is the actual warning note)
( function( wp ) { wp.data.dispatch('core/notices').createNotice( 'warning', // Can be one of: success, info, warning, error. 'Please remember to add a featured image and choose a category.', // Text string to display. { isDismissible: true, // Whether the user can dismiss the notice. // Any actions the user can perform. } ); } )( window.wp );
-
Now tell WordPress that you want to use that code by enqueuing the JS in the child theme’s functions.php:
function alerts_enqueue() { wp_enqueue_script('alerts-script', get_stylesheet_directory_uri() . '/js/alerts.js'); } add_action( 'enqueue_block_editor_assets', 'alerts_enqueue' );
If you’re using the classic editor or another block editor this will not work.
I’d also suggest just requiring the featured image and/or category
selection if you really want the users abide by the “rules”. 🙂