• Nidhi Jain

    (@jainnidhi)


    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)
  • swayam.tejwani

    (@swayamtejwani)

    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)
  • The topic ‘Want to create an admin notice on theme activation.’ is closed to new replies.