Home / Admin / Export Categories and Tags
Duplicate Snippet

Embed Snippet on Your Site

Export Categories and Tags

Export Categories and Tags

Code Preview
php
<?php
function export_tags_and_categories() {
    $terms = get_terms( array( 'category', 'post_tag' ), array( 'hide_empty' => false ) );
    $output = fopen( 'php://output', 'w' );
    fputcsv( $output, array( 'Term ID', 'Name', 'Slug', 'Description', 'Taxonomy' ) );
    foreach ( $terms as $term ) {
        fputcsv( $output, array(
            $term->term_id,
            $term->name,
            $term->slug,
            $term->description,
            $term->taxonomy
        ) );
    }
    fclose( $output );
}
function add_export_tags_and_categories_page() {
    add_menu_page(
        'Export Tags and Categories',
        'Export Tags and Categories',
        'manage_options',
        'export-tags-and-categories',
        'export_tags_and_categories'
    );
}
add_action( 'admin_menu', 'add_export_tags_and_categories_page' );
function add_export_tags_and_categories_page() {
    add_menu_page(
        'Export Tags and Categories',
        'Export Tags and Categories',
        'manage_options',
        'export-tags-and-categories',
        'export_tags_and_categories'
    );
}
add_action( 'admin_menu', 'add_export_tags_and_categories_page' );
function add_export_tags_and_categories_page() {
    add_menu_page(
        'Export Tags and Categories',
        'Export Tags and Categories',
        'manage_options',
        'export-tags-and-categories',
        'export_tags_and_categories'
    );
}
add_action( 'admin_menu', 'add_export_tags_and_categories_page' );
function add_export_tags_and_categories_script() {
    wp_enqueue_script(
        'export-tags-and-categories-script',
        plugins_url( 'export-tags-and-categories.js', __FILE__ ),
        array( 'jquery' ),
        '1.0',
        true
   

Comments

Add a Comment