
我正在尝试找出我可以使用什么操作钩子/过滤器来在管理"edit.php“页面上插入内容(我想在”posts“表上放置一些链接)?我找到了"edit_form_after_title“和"edit_form_after_editor”(它们做的正是我想做的,但它们是用于posts.php的,而不是edit.php的)。
发布于 2013-02-10 13:38:18
如果您只是想添加到帖子标题链接,您可以这样做
if (is_admin()) {
    add_filter('the_title', function($title) {
        return $before_title . $title . $after_title;
    });
}但是,听起来您并不想在标题链接中添加文本。
要在标题之后和操作链接之前添加html,可以这样做
if (is_admin()) {
    add_filter('post_row_actions', function($args) {
        // echo your custom content here
        return $args; // and dont forget to return the actions
    });
}也有用于页面编辑屏幕的page_row_actions (post_row_actions仅用于帖子)
至于在标题前添加内容,我不认为有钩子/过滤器可以做到这一点。如果您想亲自查看,请参阅wp-admin/class-wp-posts-list-table.php第463行function single_row。
发布于 2015-10-02 03:24:00
借助这个答案:How do you create a custom edit.php / edit pages page
我想出了这个:
<?php
# Called only in /wp-admin/edit.php pages
add_action( 'load-edit.php', function() {
  add_filter( 'views_edit-talk', 'talk_tabs' ); // talk is my custom post type
});
# echo the tabs
function talk_tabs() {
 echo '
  <h2 class="nav-tab-wrapper">
    <a class="nav-tab" href="admin.php?page=guests">Profiles</a>
    <a class="nav-tab nav-tab-active" href="edit.php?post_type=talk">Talks</a>
    <a class="nav-tab" href="edit.php?post_type=offer">Offers</a>
  </h2>
 ';
}
?>它看起来像这样:

https://stackoverflow.com/questions/14794910
复制相似问题