How to add notice text above Post Editor?

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.

  1. Add a new directory “js”.

  2. In that directory add a new file called “alerts.js”

  3. 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 );
    
  4. 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”. 🙂

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)