I am trying to add custom button on top of post type page like this image
Is there any filter or action I can use to add custom button there?
Thanks
I am trying to add custom button on top of post type page like this image
Is there any filter or action I can use to add custom button there?
Thanks
You must be logged in to post a comment.
I found a way to get it done but I am not very happy with this procedure. Please add your answer if you find better way. Mean while, this might be of help.
I only need this on edit page, so I am using
admin_head-edit.php
action, but you can useadmin_head
or some other (not very specific requirement)Digging into WordPress core code i did not find any hook or any filter for that buttonm you can also see that code from line no 281 to line number 288 . But you can add your button here according to this filter.
Hope it helps you.
If you are using the class WP_Lists_table (and you should) then this is the right way to do it:
The accepted answer is sadly still the only one that works.
But as the admin heading changed since it was answered, the correct script should now be :
Unfortunately there is no hook called after showing the “Add New” button.
The closest possible place to add anything without using javascript is below the title and “Add new” like this:
In my example I added a button to my custom post type “Event” using the hook “edit_form_top”:
The answer of Touqeer Shafi got me in the right direction, I needed to add a button at the top of my table view for a custom post type (book), I only had to change the post part in the
views_edit-post
to make it work:Now in 2022 with WP 5.9.1, I combined answers from Geza Gog and Tameroski, and it works great: