Skip to content

Instantly share code, notes, and snippets.

@josephhinson
Created August 4, 2015 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephhinson/7a833fb3b97291c9adce to your computer and use it in GitHub Desktop.
Save josephhinson/7a833fb3b97291c9adce to your computer and use it in GitHub Desktop.
Quick dump of all tags and categories into a table with their name, slug, and count (in descending order of count)
<?php
$args = array(
'orderby' => 'count',
'order' => 'DESC',
'hide_empty' => true,
'exclude' => array(),
'exclude_tree' => array(),
'include' => array(),
'number' => '',
'fields' => 'all',
'slug' => '',
'parent' => '',
'hierarchical' => true,
'child_of' => 0,
'childless' => false,
'get' => '',
'name__like' => '',
'description__like' => '',
'pad_counts' => false,
'offset' => '',
'search' => '',
'cache_domain' => 'core'
);
$terms = get_terms(array('category'), $args);
echo "<h3>Categories</h3>";
echo '<table style="width: 100%;">';
foreach ($terms as $term) {
echo '<tr>';
echo '<td>'.$term->name.'</td>
<td>'.$term->slug.'</td>
<td>'.$term->count.'</td>
</tr>';
}
echo '</table><hr>';
$terms = get_terms(array('post_tag'), $args);
echo "<h3>Post Tag</h3>";
echo '<table style="width: 100%;">';
foreach ($terms as $term) {
echo '<tr>';
echo '<td>'.$term->name.'</td>
<td>'.$term->slug.'</td>
<td>'.$term->count.'</td>
</tr>';
}
echo '</table>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment