Category ID and Name List

DescriptionWordpress snippet by - 03/26/10

Add this to your wordpress functions.php file to create a list of categories and their id's in the wordpress dashboard. This is great for developers and helps to keep custom pages in line, like category-21.php

Tags ,

<?php 
//Category ID ~ Name List
function hyper_id_name_widget_function() {
  
     $categories=get_categories('orderby=id');
     foreach($categories as $category) { 
          echo '<p>Cat ' . get_cat_ID($category->name) . ' = <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p>';
     } 
}
function hyper_id_name_widget() {
    wp_add_dashboard_widget('hyper_id_name_widget', 'Category ID ~ Name List', 'hyper_id_name_widget_function');
}
add_action('wp_dashboard_setup', 'hyper_id_name_widget' );

?>
  • Share
Authored by: Adam J Nowak
http://hyperspatial.com

Comments and Feedback