好了,我在当前的开发中对其进行了测试,效果良好。它将post\\u type查询参数添加到所有编辑链接,甚至在自定义帖子类型和管理栏上也是如此。这甚至可以与预先存在的查询参数一起使用,我还有其他正在运行的插件(f.ex.wpml)。
function so370070_admin_url($url, $path)
{
if (strpos($path, "post.php") !== false) :
$post_type = get_post_type();
if ($post_type) :
$url = add_query_arg(\'post_type\', $post_type, $url);
endif;
endif;
return $url;
}
add_filter(\'admin_url\', \'so370070_admin_url\', 10, 2);
由您自己解决,以下是附件的链接:
function so370070_register_post_type_args($args, $post_type)
{
if ($post_type == \'attachment\') {
//NOTE: This "_edit_link" arg is noted for Wordpress\'s internal use only
//in /wp-includes/post.php around line 84
//However, we are using a dveloper\'s filter to adjust it, so use accordingly
//that you understand it may need tweaked if Wordpress itself makes changes
//Overall it should be generally safe... no issues so far :)
$args[\'_edit_link\'] = add_query_arg(\'post_type\', \'attachment\', $args[\'_edit_link\']);
}
return $args;
}
add_filter(\'register_post_type_args\', \'so370070_register_post_type_args\', 10, 2);