You can use admin_notices
hook
http://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices
For example:
function ravs_admin_notice() {
?>
<div class="error">
<p><?php _e( 'Article with this title is not found!', 'my-text-domain' ); ?></p>
</div>
<?php
}
on publish_{your_custom_post_type}
hook
http://codex.wordpress.org/Post_Status_Transitions
function on_post_publish( $ID, $post ) {
// A function to perform actions when a {your_custom_post_type} is published.
$post_exists = $wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name="" . $_POST["article_name'] . "' AND post_type="post"", 'ARRAY_A');
if($post_exists)
update_post_meta($id, 'article_name', strip_tags($_POST['article_name']));
else
add_action( 'admin_notices', 'ravs_admin_notice' );
}
add_action( 'publish_{your_custom_post_type}', 'on_post_publish', 10, 2 );
Related Posts:
- wordpress plugin error handling
- How can I fix those issues generated by the Themecheck plugin
- Undefined property: stdClass::$labels in general-template.php post_type_archive_title()
- The editor has encountered an unexpected error. // TypeError: Cannot read property ‘prefix’ of null
- Full-Ajax Theme: parseJSON error while building a JSON object from a WordPress custom template
- wp is not defined error using wp.media to create a custom image uploader
- Check Title Unique Or Not and If not error message and dont save
- Notice: Undefined index: error and understanding wordpress
- Illegal offset type in get_post_type_object()?
- Trouble with CPT Child 404
- Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”
- Query not work for current taxonomy
- Custom Post Type and Breadcrumbs Conflict
- Custom Post Type Causes Error: Warning: call_user_func_array()
- I have a random letter appearing before my content. Where to start looking for the cause?
- “A post type mismatch has been detected” Error when updating custom post
- Error [Column ‘post_title’ cannot be null] when title is disabled for Custom post type
- Notices when submitting custom post type from front-end
- Custom Post Type slug has the same Redirection entry
- Automatically sorting custom post type admin area by a custom field
- Add / Remove Post Type from “Link to existing content” popup
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- Child pages on hierarchical Custom Post Types 404s
- Need some templating advice for templating with custom post types and taxonomies
- Filter posts with ajax form and checkboxes
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- Add New Post (Custom Post Type) Deletes 1 Post’s Custom Meta Data
- Insert slider (Custom Post Type) into pages
- get terms that have post with custom post type between 2 values
- Custom Scripts per page or Custom Post Type
- Custom Post Type not appearing in website search
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- Count posts with specific term_meta
- Custom search for custom post meta with pre_get_posts interferes with WP search
- Need to display same custom post type on 2 different singles templates
- submenu item edit a specific post
- get_posts of Custom Post Type AND Custom Taxonomy
- Tag page with Custom Post Types not returning any posts
- With two custom post types, how to make one a child of the other in the admin menu?
- Get parent categories of custom post type
- Advanced or not so advanced pre_get_posts query
- Querying both pages and posts
- WordPress sort search results by custom order
- Pagination issue on category.php using custom post type query
- How to change permalink to include custom post type
- Pages are not saving due to custom post type
- Listing all term items alphabetically / sorting loop
- save_post custom post type ? $_POST not working?
- Change the Custom Taxonomy URL Slug pattern
- Load Next WordPress Posts With AJAX?
- Add a custom meta box for client to order CPT posts how they want
- Add categories to a page with out using Custom Post Types
- Gravity forms multiple posts generated by one form [closed]
- Implementing Pillar Posts; Long Posts yet with Some Page-Like Handling?
- CPT Columns doesn’t show categories
- Role capabilities issue
- Custom Post Type “MUST NOT” be able to search via URL
- Custom taxonomy template list not working (404)
- Query for post and costom post_type in same category filtered by meta for post_type
- List latest post out of 2 custom post types
- Adding custom post formatting options in custom post types
- Calling related posts to a custom post type, taxonomy & Tag id
- How to get custom post type title, excerpt, thumbnail and permalink by post ID?
- Adding Page Ordering to a Custom Page Type
- How to properly use Categories with Custom Post Types
- Prevent user from editing others posts
- Better in the long run to use post date or custom taxonomy to sort/separate posts by year?
- Get post-meta value of all custom-posts – lowest to highest year-count?
- One Custom Post Type two different Templates
- Custom Post Type Query W/Category Dropdown
- On click some element i want to use some template
- Pin posts to top of custom loop
- Remove custom taxonamy slug with pagination
- How do I link to a dynamic ACF button from a Custom Post type?
- Hook create / update post
- Show Post columns to specific users on condition
- Change picture attachment meta of all occurrences of a picture
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- How to use costum database table for custom post type
- connect users to Custom post types
- Populate custom post type/custom fields from an external database
- Making my custom column sortable
- date_query won’t accept day parameter, but will accept month and year for a custom post
- the_permalink() leads back to homepage
- Custom Post Type Pagination Not Working or Single Posts Displaying?
- 404 error Custom search results page for custom post types with friendly URL
- Prevent repetitive terms in get_the_term_list
- Generate custom RSS from a plugin
- Custom metabox value not saving
- Category / Custom Post Type permalink issue
- Paged within a custom content type template [duplicate]
- is_singular won’t call my functions?
- loop through custom post-type with two meta_keys
- Generating custom URL before post is published
- How do i make a listing page of custom post type?
- How to add post type in masonry posts elementory widget
- How to exclude certain portfolios from a loop
- Add post id to url instead of WordPress default -2 suffix