为自定义wordpress帖子类型创建常规链接

时间:2013-02-14 07:41:33

标签: wordpress-plugin wordpress

我正在尝试添加指向现有插件的管理菜单的链接。此链接应指向服务器上从服务器下载csv文件的脚本。

我添加了一行 - *'all_items'=> __('下载捐赠者','pfund'),* ,下载捐赠者选项出现在菜单中。目前该项目指向edit.php。 如何让此链接指向csv生成脚本所在的插件文件夹?

$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(
            'title'
        ),
        'capabilities' => array(
            'edit_post' => 'edit_campaign'
        ),
        'map_meta_cap' => true
    );
    register_post_type( 'pfund_campaign', $campaign_def );
    register_post_type( 'pfund_campaign_list' );

1 个答案:

答案 0 :(得分:0)

请不要再发帖了。

试试这个:

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

function download_donors($actions, $post){
    //check for your post type
    if ($post->post_type =="pfund_campaign"){
        //remove the default edit
        unset($actions['edit']);
        //set new action
        $actions['download_donors'] = '<a href="http://www.google.com">Download Donors</a>';
    }
    return $actions;
}