Skip to content

Instantly share code, notes, and snippets.

@sudar

sudar/dump-taxonomies.php

Last active Jan 30, 2017
Embed
What would you like to do?
Dump All Taxonomies for debugging
<?php
/**
* Plugin Name: Dump Taxonomy
* Plugin URI: http://bulkwp.com
* Description: Dump all Taxonomy for debugging
* Version: 0.1
* License: GPL
* Author: Sudar
* Author URI: http://sudarmuthu.com/
*/
function dump_taxonomies() {
error_log( '========= Dump Taxonomy Start' );
$taxs = get_taxonomies( array(
'public' => true,
'_builtin' => false,
), 'objects'
);
error_log( 'Taxonomy List: ' );
error_log(var_export($taxs, true));
$terms_array = array();
if ( count( $taxs ) > 0 ) {
foreach ( $taxs as $tax ) {
$terms = get_terms( $tax->name );
error_log( 'Terms for Taxonomy ' . $tax->name . 'are the following.' );
error_log(var_export($terms, true));
if ( count( $terms ) > 0 ) {
$terms_array[ $tax->name ] = $terms;
}
}
}
error_log(var_export($terms_array, true));
error_log( '========= Dump Taxonomy End' );
}
add_action( 'init', 'dump_taxonomies' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.