How can I remove the “Add New” button in my custom post type?

Please refer below : function disable_new_posts() { // Hide sidebar link global $submenu; unset($submenu[‘edit.php?post_type=CUSTOM_POST_TYPE’][10]); // Hide link on listing page if (isset($_GET[‘post_type’]) && $_GET[‘post_type’] == ‘CUSTOM_POST_TYPE’) { echo ‘<style type=”text/css”> #favorite-actions, .add-new-h2, .tablenav { display:none; } </style>’; } } add_action(‘admin_menu’, ‘disable_new_posts’);

Custom Post Type Slug / Page Slug Conflict – Prevent use of reserved slug on page save?

The following 2 filters allow you to hook into when WordPress checks the slug and are found in the function wp_unique_post_slug() in the wp-includes/post.php file. There are 2 filters, one for hierarchical posts and one for non-hierarchical. The hierarchical filter provides the ID for the post parent so if the $post_parent is 0, you know … Read more

don’t publish custom post type post if a meta data field isn’t valid

You can stop the post from saving all together with minor JQuery hacks and validate the fields before saving on the client side or server side with ajax: first we add our JavaScript to capture the submit/publish event and use it to submit our own ajax function before the actual submit: add_action(‘wp_print_scripts’,’my_publish_admin_hook’); function my_publish_admin_hook(){ if … Read more

Filter by custom field in custom post type on admin page

And for displaying result for Filter then try this code add_filter( ‘parse_query’, ‘prefix_parse_filter’ ); function prefix_parse_filter($query) { global $pagenow; $current_page = isset( $_GET[‘post_type’] ) ? $_GET[‘post_type’] : ”; if ( is_admin() && ‘competition’ == $current_page && ‘edit.php’ == $pagenow && isset( $_GET[‘competition-name’] ) && $_GET[‘competition-name’] != ” ) { $competition_name = $_GET[‘competition-name’]; $query->query_vars[‘meta_key’] = ‘competition_name’; … Read more

How do I change the author of a custom post type?

in Custom Post Type register arguments array use this ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’, ‘comments’, ‘author’), This will activate author box on the edit screen. After registering author to cpt you need to activate author from edit screen option ( top of the edit screen where you can enable/disable all metabox ) to display authorbox … Read more

Custom Post Type Next/Previous Link?

If you need next/previous links for single posts, there is the built in next_post_link function and matching previous_post_link, both of which should probably be used within the loop. For archives, use next_posts_link and previous_posts_link. All of these will work fine with custom post types.