I create a custom post type like this:
add_action( 'init', function() {
$args = array(
'description' => '',
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_rest' => false,
'rest_base' => '',
'has_archive' => false,
'show_in_menu' => true,
'exclude_from_search' => false,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array(
'slug' => 'job',
'with_front' => false
),
'query_var' => true,
'supports' => array(
'title'
),
'label' => 'Jobs',
'labels' => array(
'name' => 'Jobs',
'singular_name' => 'Job',
'menu_name' => 'Jobs',
'all_items' => 'All Jobs',
'add_new_item' => 'Add New Job',
'new_item' => 'New Job',
'edit_item' => 'Edit Job',
'view_item' => 'View Job',
'featured_image' => 'Job Photo'
),
);
register_post_type( 'job', $args );
} );
You can see I have public
and publicly_queryable
set to false
.
However, when I create a new post or update it, it says "Post updated. View post" where "View post" is a link to the post. This post is not public so it should not have a "View post" link. How can I stop it from adding this link to the updated message?
I create a custom post type like this:
add_action( 'init', function() {
$args = array(
'description' => '',
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_rest' => false,
'rest_base' => '',
'has_archive' => false,
'show_in_menu' => true,
'exclude_from_search' => false,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array(
'slug' => 'job',
'with_front' => false
),
'query_var' => true,
'supports' => array(
'title'
),
'label' => 'Jobs',
'labels' => array(
'name' => 'Jobs',
'singular_name' => 'Job',
'menu_name' => 'Jobs',
'all_items' => 'All Jobs',
'add_new_item' => 'Add New Job',
'new_item' => 'New Job',
'edit_item' => 'Edit Job',
'view_item' => 'View Job',
'featured_image' => 'Job Photo'
),
);
register_post_type( 'job', $args );
} );
You can see I have public
and publicly_queryable
set to false
.
However, when I create a new post or update it, it says "Post updated. View post" where "View post" is a link to the post. This post is not public so it should not have a "View post" link. How can I stop it from adding this link to the updated message?
Share Improve this question asked Nov 21, 2019 at 11:30 GavinGavin 4347 silver badges21 bronze badges1 Answer
Reset to default 1to customise messages on edit page, you can use this filter :
add_filter("post_updated_messages", function ($messages) {
$post_type = "job";
if ($post_type === $GLOBALS["post_type"]) {
$messages[$post_type] = [
1 => "the object is updated",
6 => "the object is created",
];
}
return $messages;
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744983220a4604462.html
评论列表(0条)