Add custom post notice after post delete

I am trying to add a custom info notice after the post has been deleted from the trash, but I’m not having any luck with it add_action( ‘delete_post’, ‘show_admin_notice’ ); /** * Show admin notice after post delete * * @since 1.0.0. */ function show_admin_notice(){ add_action( ‘admin_notices’, ‘show_post_order_info’ ); } /** * Display notice when … Read more

Undefined property: stdClass::$labels in general-template.php post_type_archive_title()

I’ve got a custom post type with a standard tag taxonomy added to it like so: ‘taxonomies’ => array(‘post_tag’). I’ve added some tags to some posts of this CPT which are display on the front-end with the template tag the_tags() and the links it generates have this format http://local.mysite.dev/tag/tag1/. When I click such a link … Read more

WordPress admin notice in plugin function

i have sample wordpress plugin class. Im hooking woocommerce woocommerce_saved_order_items and i want create a admin notice. Add action from __construct works, but when i want create a notice in hook function it doesnt appears, where is the problem? class SomeClass { private static $instance; public function __construct() { add_action(‘woocommerce_saved_order_items’,array($this,’orderStatusChange’),10,1); add_action(‘admin_notices’, array($this,’simple_notice’)); // This works … Read more

How to customize post edit notices

How to customize the notice message (‘Post published’ or ‘Post updated’) displayed when I add or edit a custom post type registered with register_post_type() function? 2 Answers 2 You can used the post_updated_messages filter. add_filter( ‘post_updated_messages’, ‘rw_post_updated_messages’ ); function rw_post_updated_messages( $messages ) { $post = get_post(); $post_type = get_post_type( $post ); $post_type_object = get_post_type_object( $post_type … Read more

How to Make an admin_notices Message That Disappears Once the User Leaves That Particular Page?

It’s easy enough to find help with admin_notices which: show permanently in the admin screen only show when a particular kind of page is shown show until the user dismisses it But I can’t find help with creating a message which shows until the user leaves that particular page. ie. exactly what WordPress shows routinely … Read more

Hide php Notices in Dashboard

When I program a theme, I put WP-DEBUG on. Which ensure a proper PHP code. Sadly most Plugin developers keep using non existing vars : echo $args[‘title’]; Notice: Undefined index: title in /wp-content/plugins/easy-fancybox/easy-fancybox.php on line 301 Instead of echo ( isset($args[‘title’]) ? $args[‘title’] : ” ); So I permanently get tens of Notice errors with … Read more

get_the_ID() gives notice in 404 page

I’m using get_the_ID() in my wp_enqueue_scripts action due to some needs, But as result I’m getting the following notice (wp-debug is on): Notice: Trying to get property of non-object in C:\wamp\www\WordPress\wp-includes\post-template.php on line 29 I know why this happens, My question is why should this happen? Isn’t WordPress supposed to know that there is no … Read more

How to stop showing admin notice after close button has been clicked

First of all I do know how to add admin notice in the wordpress admin menu. And I added an admin notice like this: <?php add_action( ‘admin_notices’, function() { ?> <div class=”notice notice-success is-dismissible”> <p><?php _e( ‘Imagine something here!’, ‘sample-text-domain’ ); ?></p> </div> <?php }); Now my code is running fine and smooth, just with … Read more