WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a custom button and link it to a file within the plugin. How do I get this link pointing to the path of my choice?

Download Donors should point to the link I choose

I've tried the following but it does now work.

function _pfund_register_types() {
    $pfund_options = get_option( 'pfund_options' );
    $template_def = array(
        'public' => true,
        'query_var' => 'pfund_cause',
        'rewrite' => array(
            'slug' => $pfund_options['cause_slug'],
            'with_front' => false,
        'hierarchical' => true,
        'label' => __( 'Causes', 'pfund' ),
        'labels' => array(
            'name' => __( 'Causes', 'pfund' ),
            'singular_name' => __( 'Cause', 'pfund' ),
            'add_new' => __( 'Add New Cause', 'pfund' ),
            'add_new_item' => __( 'Add New Cause', 'pfund' ),
            'edit_item' => __( 'Edit Cause', 'pfund' ),
            'view_item' => __( 'View Cause', 'pfund' ),
            'search_items' => __( 'Search Causes', 'pfund' ),
            'not_found' => __( 'No Causes Found', 'pfund' ),
            'not_found_in_trash' => __( 'No Causes Found In Trash', 'pfund' ),
    register_post_type( 'pfund_cause', $template_def );
    register_post_type( 'pfund_cause_list' );

    $campaign_def = array(
        'public' => true,
        'query_var' => 'pfund_campaign',
        'rewrite' => array(
            'slug' => $pfund_options['campaign_slug'],
            'with_front' => false
        'hierarchical' => true,
        'label' => __( 'Campaigns', 'pfund' ),
        'labels' => array(
            'name' => __( 'Campaigns', 'pfund' ),
            'singular_name' => __( 'Campaign', 'pfund' ),
            'add_new' => __( 'Add New Campaign', 'pfund' ),
            'add_new_item' => __( 'Add New Campaign', 'pfund' ),
            'download_donors' => __( 'Download Donors', 'pfund' ),
            'all_items' => __( 'Download Donors', 'pfund' ),
            'edit_item' => __( 'Edit Campaign', 'pfund' ),
            'view_item' => __( 'View Campaign', 'pfund' ),
            'search_items' => __( 'Search Campaigns', 'pfund' ),
            'not_found' => __( 'No Campaigns Found', 'pfund' ),
            'not_found_in_trash' => __( 'No Campaigns Found In Trash', 'pfund' ),
        'supports' => array(
        'capabilities' => array(
            'edit_post' => 'edit_campaign'
        'map_meta_cap' => true
    register_post_type( 'pfund_campaign', $campaign_def );
    register_post_type( 'pfund_campaign_list' );

Notice the lines

'download_donors' => __( 'Download Donors', 'pfund' ),
        'all_items' => __( 'Download Donors', 'pfund' ),

The 'download_donors' label doesn't work. I have to use the 'all_items'. Not sure why this is but when I try to add the filter it doesn't get overwritten. Instead the link points to wp-admin/edit.php?post_type=pfund_campaign

add_filter('post_row_actions','all_items', 10, 2);

function download_donors($actions, $post){
    //check for your post type
    if ($post->post_type =="pfund_campaign"){
        //remove the default edit
        //set new action
        $actions['download_donors'] = '<a href="http://www.google.com">Download Donors</a>';
    return $actions;
share|improve this question
up vote 1 down vote accepted

I'm not sure where you got the idea that adding 'download_donors' would do what you want, it's nowhere in the documentation, and it IS being bundled with the labels, it's just that nothing makes use of it.

The labels when registering a post type are not definitions for admin menus.

If you want to add an admin menu, you need to do it the same way everything else does it via add_submenu_page



add_action('admin_menu', 'register_my_custom_submenu_page');

function register_my_custom_submenu_page() {
    add_submenu_page( 'tools.php', 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback' ); 

function my_custom_submenu_page_callback() {
    echo '<h3>My Custom Submenu Page</h3>';


Making the menu link to an external page won't be possible, you'd need to intercept the page load and do a wp_redirect call, but that would be misleading to the user and bad UI. You'd be better off putting a big download button on your new subpage

share|improve this answer
It wouldn't be going to an external link. i have a php script that downloads a csv file to the user's browser. this script is in the same plugin folder – Julian Feb 15 '13 at 9:52
Where it goes is irrelevant, linking to an external, an internal, or anywhere like that is not an option. You have no control over the url it generates for the new page via those APIs – Tom J Nowell Feb 15 '13 at 10:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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