我是wordpress和网页设计师的大三学生,我想问一个愚蠢的问题。
在wordpress网站上,当我创建新帖子并提交时。该页面将回退以编辑帖子页面。但我希望它可以重定向到这个相关的帖子或页面。如何使用编码或插件更改此设置?
我发现这篇文章是新的。php,但我不知道如何实现我的目标。谢谢
if ( \'post\' == $post_type ) {
$parent_file = \'edit.php\';
$submenu_file = \'post-new.php\';
} elseif ( \'attachment\' == $post_type ) {
if ( wp_redirect( admin_url( \'media-new.php\' ) ) )
exit;
} else {
$submenu_file = "post-new.php?post_type=$post_type";
if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
$parent_file = $post_type_object->show_in_menu;
// What if there isn\'t a post-new.php item for this post type?
if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
if ( isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
// Fall back to edit.php for that post type, if it exists
$submenu_file = "edit.php?post_type=$post_type";
} else {
// Otherwise, give up and highlight the parent
$submenu_file = $parent_file;
}
}
} else {
$parent_file = "edit.php?post_type=$post_type";
}
}
最合适的回答,由SO网友:Lucien Dubois 整理而成
你应该看看redirect_post_location filter
以下是一个片段:
add_filter( \'redirect_post_location\', \'yourcustom_redirect_post_location\' );
function yourcustom_redirect_post_location( $location, $post_id ) {
if ( isset( $_POST[\'save\'] ) || isset( $_POST[\'publish\'] ) ){
return get_permalink( $post_id );
}
return $location;
}