Support » Fixing WordPress » Want to create an admin notice on theme activation.

  • Hi,

    Can anyone help me to create an admin notice on theme activation.

    I want to create an admin notice on theme activation. And it will disappear when clicking on the close icon.

    I’ve tried but when we refresh the page it shows again.

    Can anyone just help me out?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Hi Nidhi,

    you can add this below code in your theme functions.php file

    
    if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
    	add_action( 'admin_notices', 'my_theme_activation_notice' );
    }
    
    function my_theme_activation_notice(){
        ?>
        <div class="updated notice is-dismissible">
            <p>Thank you for activating this theme <strong>You are awesome</strong>.</p>
        </div>
        <?php
    }
    

    this will show notice as soon as your theme is activated and you can close it using close icon. Let me know if this works for you.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.