WordPress: Add content to edit.php

enter image description hereI’m trying to find out what action hook/filter I can use to insert content on the admin “edit.php” page (i want to place a few links above the ‘posts’ table)? I’ve found “edit_form_after_title” and “edit_form_after_editor” (these do exactly what I want to do, but they are for posts.php, not edit.php).

Related posts

Leave a Reply

2 comments

  1. With the help of this answer: How do you create a custom edit.php / edit pages page

    I came up with this:

    <?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>
     ';
    }
    ?>
    

    And it looks like this:

  2. If you just wanted to add to the post title link you could do something like this

    if (is_admin()) {
        add_filter('the_title', function($title) {
            return $before_title . $title . $after_title;
        });
    }
    

    however, it doesn’t sound like you want to add text to the title link.

    To add html after the title and before the actions links, you could do like this

    if (is_admin()) {
        add_filter('post_row_actions', function($args) {
            // echo your custom content here
            return $args; // and dont forget to return the actions
        });
    }
    

    There is also page_row_actions for the page edit screen (post_row_actions is only for posts)

    As far as adding stuff before the title, I don’t see a hook/filter to do that. See wp-admin/class-wp-posts-list-table.php line 463 function single_row if you want to look for yourself.