2

我想更改编辑帖子链接的 URL,以便将您定向到我自己的自定义编辑页面。我一直在寻找过滤器或功能,但我能找到的只是edit_post_link()功能和get_edit_post_link()功能。从我从文档中可以看到,edit_post_link只更改链接文本,而不是 URL。我get_edit_post_link相信会为您获取 URL。

4

3 回答 3

4

您需要将过滤器添加到get_edit_post_link. 这是未经测试的,但类似于:

add_filter( 'get_edit_post_link', 'my_edit_post_link' );
function my_edit_post_link( $url, $post->ID, $context) {
    $url = //However you want to generate your link

    return $url;
}
于 2013-02-04T02:23:43.223 回答
1

工作版本:

add_filter( 'get_edit_post_link', 'my_edit_post_link', 10, 3 );
function my_edit_post_link( $url, $post_id, $context) {
    $url = "http://somethingerother.com/custom_post_editor.php?post=".$post_id; // Modify the URL as desired

    return $url;
}
于 2020-08-06T17:14:53.873 回答
0

我的 wordpress 开发技能有点生疏,但你可能应该使用 wordpress挂钩来挂钩edit_post ,并编写你的插件来重写返回值或do_action只是去你自己的自定义编辑页面

于 2013-02-03T23:25:10.410 回答