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
- Loading External Scripts in Admin but ONLY for a Specific Post Type?
- Hide/Show only specific categories in wp-admin new-post.php
- Date archives for custom post type
- How do I redirect all 404 errors of a specific post type to another URL?
- Unable to filter on field on edit.php page
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- How to Change the Title of a Meta Box on a Specified Custom Post Type? [duplicate]
- How to save the checked boxes?
- How to get only one category of custom post type?
- Changing the header on post listing page in admin area
- template_redirect not working, apparently for no reason
- Append taxonomy terms as class names in markup?
- Using WPAlchemy metabox values in another metabox
- Display custom field of specific post where post title matches variable
- GravityForm: Populate Dropdown with custom post type [closed]
- How to output wordpress custom tags separated by comma?
- Show Different Header on a Specific Post ID
- Custom Post Type rewrite
- submenu item edit a specific post
- get_posts of Custom Post Type AND Custom Taxonomy
- If post has custom field then display css-class
- How to add a custom taxonomy to show up in a custom post type menu?
- Replace text in post from cvs
- Get parent categories of custom post type
- Give a permalink to Custom Post Types without title
- Selecting a post in Dashboard
- Custom Tag Description unable to display just below and outside of the Loop
- Can one create multiple Custom Post Types with a for loop?
- How to add custom field to view-edit post type page
- Custom Field values not Showing in Edit Page of Custom Post Type
- Add first letter of titles to array, then compare arrays
- Dynamically insert code to custom post type loop
- widget_posts_args not using the number of posts in widget
- How To Post WordPress Custom Post Types to Twitter via IFTTT
- Undefined $post in wp_query
- Copy order items with metadata between orders – Woocommerce
- How to add and display custom content that is not a post
- List latest post out of 2 custom post types
- How do I edit the WordPress post.php file?
- Add data to post edit page, when post is published
- How to get the custom post data using post id in WordPress?
- See if the email exists or not
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- list articles in admin showing nested categories or slugs?
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- Why are custom taxonomies only appearing on the edit page of one of these types, but not the other?
- Problem with checked box on wp car manager plugin
- URL issue retrieving Custom Post Types using Backbone JS API
- WordPress Custom Post Loop
- Add Custom Field in Product in WP Admin and send to Order Webhook
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- programmatically generated custom post type is created more than once
- Accessing download link from the loop with WP Download Manager Pro
- Create posts inside CPT post
- Taxonomies are not showing in the category dropdown
- Show Post columns to specific users on condition
- Custom Taxonomy – fields
- Print post category name from a custom post type wordpress
- CPT post doesnt shows tags and category on backend admin page
- call a function when insert and update a custom post type
- Registering an optional custom post type from a plugin
- Get month and day from a Date Picker custom field
- Generate custom RSS from a plugin
- Change the text on the Publish button
- is_singular won’t call my functions?
- Inserting two categories
- Comments are not working on Custom Post Type
- Send email on creation of custom post type and use get_post_meta()
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs