The add_action
function only adds the action to a queue, which will be executed when the corresponding do_action
is called. So, when you queue it too late, nothing will happen.
To know for sure what happens in your case, you must carefully examine the order of the hook execution. That requires insight in your complete setup, including plugins and so on.
My guess is that by the time isset($_POST['post_saved'])
is true do_action ('admin_notices')
is already executed and queueing something for it is useless.
The way to solve this is not to add the action conditionally. Always add the action and put the test inside the function. Like this:
add_action('admin_notices', 'image_error');
function image_error () {
$flag_worked = isset($_POST['post_saved']);
if ($flag_worked) {
echo 'error';
}
Related Posts:
- How can I remove the “Add New” button in my custom post type?
- Use a textarea for a custom post type
- Row actions not showing? Why?
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to append element after thumbnail
- Dynamic Custom Post Type Plugin
- How to make in WordPress admin panel sortable column for the custom field, that count the number of page impressions?
- Get all of user’s custom post types in WP Admin for plugin
- Get rewrite slug of custom post type in template
- How to customize a permalink (URL) structure?
- Use custom metabox to update automatically a post after a given date
- Addition of custom option panel crashes Media Library & Admin Area
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Problems wp_insert_post and save_posts filter
- WordPress custom post type capabilities issue
- Show current custom taxonomy
- How exclude or skip post type with get_next_post_link
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- How do I add custom HTML to the content of an archive page’s posts?
- Validate Custom Post Type fields
- Custom post type page with parameter
- Change Text in Admin Panel
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- How to show the post which checkbox is not selected
- Is it possible to get the specific content on the search page?
- Plugin Development using classes – Public & Private Callbacks
- Sort custom post column by generated value?
- Restrict Custom Post Type to One Item
- Having issue on Loading Meta Data From CSV to CPT
- How to dynamically register custom post type
- Display box in sidebar of custom post type
- how to set default value for checkbox in wordpress
- How do I include drag-and-drop in a plugin?
- Adding menu_order to CPT admin page
- Remove “Get Shortlink” button in admin of custom post type
- wordpress custom post type remove duplicate menu item
- How could I create a ‘private comments’ section on a custom post type?
- Using WPAlchemy metabox values in another metabox
- Need functionality with all post list available at edit.php
- is_page_template not working as expected
- List terms from Custom Taxonomy
- Custom Post Type get_post_type_archive_link( $post_type ) returns false
- Show hierarchical relationship between to custom post types on admin list
- Show Custom Post Type values in WordPress grid view
- How do I set the link in the Custom Post Type admin menu?
- How to List Thumbnails based on Custom Categories
- WP_Query search posts by custom post type and custom taxonomy
- Adding Meta Boxes while Registering a Post Type in a Class
- How to have the right design for a custom post type without accessing themes
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- I am having a problem with form updating/editing WordPress post on the frontend
- How to filter out post type meta?
- How to rename image at uploading on specific plugin or post-type in WordPress
- WP-Admin edit.php & post.php slowdown after import of 10k users
- handling csv data with a custom post type
- Display custom field of specific post where post title matches variable
- Conditional to modify query results
- How do I alter the position of a Custom Post Type menu item within my plugin admin menu?
- How to remove ‘create new post’ entry for a custom post type?
- Customize permalink when creating a post
- How to make post sticky in the admin page?
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- Custom Taxonomy Not Showing in Menu
- How to customize admin posts based on the user who is logged in
- Custom Post Type | Fatal Error on register_post_type()
- Output custom post shortcode. Help spot the error.
- How to count custom post types with conditional operators
- Set object terms not working on plugin activation
- Using custom page templates with plugin [duplicate]
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- WP_Query is printing out only one post when posts_per_page is set to multiple
- WP Query to displaying date and posts for that date?
- GravityForm: Populate Dropdown with custom post type [closed]
- Return array of categories to php function for current post
- Link users to a custom post type
- Create a random unique 6 digit number as custom field for custom post type
- How to output wordpress custom tags separated by comma?
- Loading all files within a directory
- Issue with pre_get_posts on custom post type archive pages
- Blog page showing same content as homepage
- Custom Post Type Navigation on Custom Field
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Change headers in admin posts list
- Using several custom fields as custom post title
- Custom Post Type without an archive page
- Plugin translation not working apart from name and description
- Show Different Header on a Specific Post ID
- Get Post Primary Category
- Weird problem happening with custom taxonmy when creating/updating posts
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Custom Post Type rewrite
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Can’t get order_by meta_value_num to work properly
- Custom Post Type: Upload Multiple Images
- Custom Post Type + 20k posts = blank/404 within Admin edit.php [duplicate]
- Create custom post type on successful woocommerce order [closed]
- Adding custom tables to WordPress
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Detect where custom post type is declared
- Metadata for a taxonomy – is there any WordPress way of doing this?