2

I have a custom post type for a plugin I'm creating and the label for the "add an item" type of button (at the top of the list page) needs a partner-button that says "import" and one that says "export" so that I can (after a brief confirmation dialogue) allow my client to push and pull the records with a JSON file that is already all set up; I just need them to be able to trigger it and I can't figure out how to add buttons to the list page.

A screenshot of the button on the edit list

So I need to add "Import" and "Export" after the "Add an Entry" button.
Any help is greatly appreciated.

3

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.

add_action('admin_head-edit.php','addCustomImportButton'));

I only need this on edit page, so I am using admin_head-edit.php action, but you can use admin_head or some other (not very specific requirement)

/**
 * Adds "Import" button on module list page
 */
public function addCustomImportButton()
{
    global $current_screen;

    // Not our post type, exit earlier
    // You can remove this if condition if you don't have any specific post type to restrict to. 
    if ('module' != $current_screen->post_type) {
        return;
    }

    ?>
        <script type="text/javascript">
            jQuery(document).ready( function($)
            {
                jQuery(jQuery(".wrap h2")[0]).append("<a  id='aspose_doc_popup' class='add-new-h2'>Import</a>");
            });
        </script>
    <?php
}
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. – cybmeta Apr 23 '15 at 6:11
  • @cybmeta: thanks for providing links as well. You could better post answer rather than raising objection. Regarding I used answer instead of comment section, I don't have enough reputation to comment, that you already know. Regarding the answer, that provided link does provide answer. – user98239820 Apr 23 '15 at 6:24
  • 1
    That comment was added automatically by the system when I reviewed your answer. Only-link based answer are not considered good answers, they should be comments. If you have not enough reputation to add comments, you can participate in the community to gain it ;). – cybmeta Apr 23 '15 at 6:27
  • 1
    This is what an answer should look like. Just to add, links rot. If a link changes or gets removed, your answer is useless for any one finding it via search engines. For this very reason, all important info should be in your question and not in a link. A link should only be used as a form of credit to the author and as a reference. Remember, your answer should serve as a reference to any one, not just the person who asked the question. In ten years time, your answer should still serve as a independant source to others. :-) – Pieter Goosen Apr 23 '15 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.