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

The short answer is: Use Query Strings. If you notice in the address bar immediately after you publish a Post… You will see something similar to this: domain.com/wp-admin/post.php?post=4935&action=edit&message=6 There’s a few different Query Variables: post contains the ID of the Post being edited. action is saying we’re currently “editing” the Post. message refers to what … Read more

Hide php Notices in Dashboard

I don’t know how to move the notices to the bottom or if that’s possible at all. To disable the debug mode in wp-admin write in wp-config.php: define( ‘WP_DEBUG’, FALSE === strpos( $_SERVER[‘REQUEST_URI’], ‘/wp-admin/’ ) ); Untested: You could try to enable warnings in admin with: // happens early in wp-admin/admin.php add_filter( ‘secure_auth_redirect’, ‘wpse_67728_error_warnings’ ); … Read more

get_the_ID() gives notice in 404 page

get_the_ID() is broken. function get_the_ID() { return get_post()->ID; } It tries to use the member ID on a function that returns a post object sometimes: /* * @return WP_Post|null WP_Post on success or null on failure */ function get_post( $post = null, $output = OBJECT, $filter=”raw” ) { get_posts() can return NULL, and NULL has … Read more

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

Two ways to handle this. a. Attach a timer to the notice: You could attach a 3-second timer (or however long you wish) to the notice, as follows: <?php set_transient( “my-plugin”, “alive”, 3 ); add_action( ‘admin_notices’, function() { //Syntax correction if ( “alive” == get_transient( “my-plugin” ) ) { ?> <div class=”notice notice-success is-dismissible”> <p><?php … Read more

How to pass parameters to admin_notices?

I think a better implementation would be a “message” class e.g.: class WPSE_224485_Message { private $_message; function __construct( $message ) { $this->_message = $message; add_action( ‘admin_notices’, array( $this, ‘render’ ) ); } function render() { printf( ‘<div class=”updated”>%s</div>’, $this->_message ); } } This allows you to instantiate the message at any time prior to rendering: … Read more

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