在post_ meta after“中;添加新的“;如何重定向到列表页


In post_meta after "add new" how to redirect to list page

我正在使用register_post_type创建post_meta,因此在添加和发布后的"添加新"功能中,它将重定向到"编辑页面"。发布后如何将其重定向到列表页?

编辑或发布后,您可以使用redirect_post_location操作挂钩将您的帖子类型重定向到所需的位置或url。

function custom_redirect($location) {
    global $post_type;
    if ($post_type == 'your post type here') {
        $location   = admin_url('edit.php?post_type=' . $post_type);
    }
    return $location;
}
add_action( 'redirect_post_location', 'custom_redirect');

它会检查你的帖子类型,并创建你帖子类型的列表页面的url,并设置新的重定向位置。

希望这能帮助你:-)