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
- Adding a new custom post type using the editor causes 502 bad gateway error
- Handling front-end file uploads, considering safety and ease of use
- How to List All Custom Post Types Names (Not Posts)
- How to add multiple images to a custom post type single post?
- Automatically fill custom field value on post publish/update
- Make permalinks based on an ACF-field
- Custom permalink with pagination
- Are custom post types suitable for storing high numbers of data elements, in this case chat messages?
- Custom Post Type with Custom Title
- Displaying custom post type by first letter through custom taxonomy
- How to Sort Custom Field Admin Column by Date
- How can I customize “Pages” admin (edit.php) and “Edit Page” admin (post.php) for bulk edit of custom content type?
- Is it possible to insert text into an html tag using functions.php?
- Get the terms of a custom taxonomy for a specific author in author template
- Pagination with custom post types results in 404 issues
- Best practice for adding posts in bulk
- Pagination in a Shortcode. Get_next_posts_link not working but get_previous_posts_link works fine right next to it
- tax_query returning all posts instead of selective posts in WP_Query
- How to limit post of custom post status?
- Get template part using a custom taxonomy term
- Taxonomies not showing up in custom post type
- Make metabox of custom post type fully autosave- and bulk-/quick-edit compatible
- Creating a Custom Post as a repository for theme constants
- Create a clone from one WordPress site to another in a few minutes
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- How do I move/order posts with a tag to the end?
- Add Pagination on Custom Post Type Archive
- WP_Query custom post type query not showing the exact post type
- Change sort order when using ‘orderby’ => ‘type’
- Why does my content disapear when I make a page to match an archive name?
- How to get WordPress term attached to the Post?
- How to automatically and randomly reorder custom post type?
- I’m having trouble getting the permalink sample on my custom post type edit page to work
- Is it a good idea to add a column to the posts table?
- How to hook WP initialization without modifying functions.php
- Is it possible to load a different sidebar in single.php based on a meta_query filter?
- Querying multiple values from a single key
- How to get_term_meta on single custom post?
- ArgumentCountError caused by wp-includes/class-wp-hook.php
- Assign a template to a custom post type when displayed by the main loop on the home page
- Custom Post Type API doesn’t show taxonomy or category array
- Shortcode with WP_Query more than once on one page
- Generating and downloading files with WP API
- CPT, meta-data, url parameter
- Difference between page and paged
- Front-end Image Upload to Custom Meta Box
- How do I list a custom field and custom taxonomies for each result in a loop?
- Letting the user define the arguments in a custom loop? (the “$custom_posts->query(…)” part)
- Using custom post types to give WordPress a more CMS-like look. What to prioritaize? Pages or Content?
- Finding the CPT archive template source
- WordPress custom post type link are changed but returns 404
- Save post action is called twice
- Custom query result empty on page 2
- How to overwrite function to display parent page combobox for custom post type in Edit Post Page?
- Meta query and compare “!=” not working as expected
- Custom Page Template – Widgets of wrong sidebar
- Display 3 level taxonomies
- Loop (for search results) returning right posts, but wrong post type
- Custom Post Type Front Page Gives 404
- Recovering data about custom post and taxonomy types
- Wrap each child and it’s grandchildren separately
- How to use two different pages to see the post content?
- Display posts on parent post if author coincides
- How to Create a Default Fixed Custom Posts layout for text and images
- How to show post which has the specific taxonomy terms?
- Paginate Custom Post, Old and New buttons not displaying
- Custom Upload Directory for Custom Post Types
- YearWise Categorywise Post
- Modify shortcode to work with custom taxonomies and slugs
- Calling the first & last post by category in custom post type
- Counting custom post type with wp_count_posts returns an empty object
- Wrong post_type argument passed to the query when using a custom post type
- Remove space when post title is blank
- Author profile comments system
- Targeting specific Page Template for sidebar page
- Code in custom widget queries all posts, when it should only query the current post
- Specific Thumbnail Size for Custom Content Type
- How to feed custom post type to a facebook page?
- Order Wp Query by earliest of 3 dates meta query
- WP Query filtering by custom category not showing all relevant posts
- How to correctly edit permalink structures for both default and custom posts/taxonomies?