PHP Notice: Undefined offset: 0

If $wp_query->post_count == 0 I cant see how $wpdb->get_results( $wp_query->request ) would return any posts. So basically $request = $wpdb->get_results( $wp_query->request ); contains nothing and $request[0] doesn’t exist. Ergo PHP Notice: Undefined offset: 0 It would be interesting to know, what this could is supposed to achieve.

Notices on the front-end

You could filter the_content: add_action( ‘post_updated’, ‘wpse105892_add_message’, 10 ); function wpse105892_add_message() { add_filter( ‘the_content’, ‘wpse105892_display_message’ ); } function wpse105892_display_message( $content ) { // remove the action once it’s run remove_action( ‘post_updated’, ‘wpse105892_add_message’, 11 ); $content = “<div class=”your-message”>You did it!</div>\n\n” . $content; return $content; }

Add custom post notice after post delete

Checking the bulk counts We can check the bulk counts, to see if any post was deleted: add_filter( ‘bulk_post_updated_messages’, function( $bulk_messages, $bulk_counts ) { // Check the bulk counts for ‘deleted’ and add notice if it’s gt 0 if( isset( $bulk_counts[‘deleted’] ) && $bulk_counts[‘deleted’] > 0 ) add_filter( ‘admin_notices’, ‘wpse_243594_notice’ ); return $bulk_messages; }, 10, … Read more