Skip to content

Instantly share code, notes, and snippets.

@sudar
Last active January 30, 2017 11:15
Show Gist options
  • Save sudar/6d0984c0938193fbd6d7538d4e188103 to your computer and use it in GitHub Desktop.
Save sudar/6d0984c0938193fbd6d7538d4e188103 to your computer and use it in GitHub Desktop.
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