我有一个函数,在一定时间后过期。它还设置自定义post状态\'expired\'
. 我希望它能像\'draft\'
发布URL不再可供公众访问。目前,一旦岗位设置为\'expired\'
, 整个permalink仍然可见。这是我的代码:
function hrl_custom_status_creation(){
register_post_status( \'expired\', array(
\'label\' => _x( \'Expired\', \'post_type_listings\' ),
\'label_count\' => _n_noop( \'Expired <span class="count">(%s)</span>\', \'Expired <span class="count">(%s)</span>\'),
\'public\' => true,
\'exclude_from_search\' => false,
\'show_in_admin_all_list\' => true,
\'show_in_admin_status_list\' => true,
\'protected\' => true,
\'_builtin\' => true
));
}
add_action( \'init\', \'hrl_custom_status_creation\' );
// change post status to \'expired\'
$postdata = array(
\'ID\' => $post_id,
\'post_status\' => \'expired\',
);
// Update post data
wp_update_post($postdata);