Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How can I display the date created for my blog categories? WordPress


On my archives page beside each category, I want to display the date it was created. Ideally, it would be something like this, though I know it doesn't exist -

<?php wp_get_post_categories('date_created=') ?>
Any ideas?

Answers (16)


Japh answers:

It would be quite doable to make a small plugin to make this information available for you.

You could create a separate database table with a category's created and modified dates and use the appropriate actions.

for example:

function cat_add($CatID) {
// Code here to add the created date to your plugin DB table


function cat_change($CatID) {
// Code here to update the modified date to your plugin DB table


function cat_remove($CatID) {
// Code here to delete the category from your plugin DB table


I could create this plugin for you if you wish. I think actually creating the plugin is probably beyond the scope of this question ;)

Hope that helps!


greggo answers:

<strong>GREAT IDEA!</strong>

Here's what you do...
Type this into your code

And that's it!


vsellis answers:

<?php the_time('F j, Y'); ?>

Will display the date as ex: January, 4, 2010


<div><?php the_time('M j, Y'); ?></div>

would display the date as Jan 4, 1020


Dan Davies answers:

Without some modification, I'm not sure how one would return the date the category was created. It played on my mind to somehow include the datestamp of the first post within each category, but then I found this <a href="">recent categories plugin</a>. I hope that helps.


vsellis answers:

Darren, I should have read your question more carefully. I looked at the wordpress database and there is nothing in the terms/taxonomies tables that captures the date you create a category so I'm not sure there is a way to do what you are looking for out of the box. It sounds like the link Dan pointed you to is your best bet


deadlyhifi answers:

As the others have said the date of category creation is not stored in the the database.

The easiest way to do it would be to type in the date in the description of the category, then output it using <?php echo category_description( $category ); ?>.
See [[LINK href=""]][[/LINK]] for more uses of this.


Jay Philips answers:

You could use this:
<?php the_time('l, F jS, Y') ?> at
<?php the_time() ?>

Which will display:
Monday, February 12, 2003 at 11:32

Or you could use this:
<?php the_time('m/j/y g:i A') ?>

Which will display:
POSTED: 05/12/04 9:35 AM


badcat answers:

As mentioned above, since the date of the category creation is not captured in the DB, might it not make sense to use the date of the first post added to that category? I guess it really depends on what the intent is here. If truly to use on an archives page, then the first post in that cat would probably suffice.

However in a situation where there are many editors, contributors and such - seeing when a particular category (ie a possible similarly named duplicate) was created might be helpful in working out editorial kinks.


steve answers:

I think it makes the most sense to use the category description field to set the date you're looking for and then pull the information using:
<?php echo category_description( $category ); ?>
As described above.


Japh answers:

If you did want to do it by putting the value into the category's description, place the following snippet in your functions.php:

function save_category_created($catID) {
$cat = (array) get_category_to_edit($catID);
$cat['category_description'] = date('U'); // Here you can format the date as you like. I put it as the timestamp for easy conversion when used.

add_action('create_category', 'save_category_created');

Then, you can just fetch the category description wherever you need it.


spivurno answers:

Japh's concept of a simple plugin to handle this functionality is by far the most ideal solution; it requires no additional user interaction and could be easily modified to give you any category meta date you might want in the future.

Entering the date in the description field requires an additional level of user interaction for every category and deprives you of the intended use of that field. Not a horrible solution, but not ideal.


Lew Ayotte answers:

Yeah, WordPress doesn't keep track of the date-time of category creation. The only two options would be to use the description field (as described above) or to add/modify a table and hook into the function that adds categories to include the date.

I had a similar need for some work I was doing a few weeks ago. The "date" wasn't necessary, but ordering the category by "date" was. I was able to achieve a similar result by ordering by category ID. Since the category IDs always increment then the "oldest" categories would have the lowest numbers.

Of course this wasn't exactly described as your need, but I thought I'd throw it in there.


Gerasimos Tsiamalos answers:

I think Japh's solution is the best. Although he mentions something about using a different db table? Wouldn't the options table do the job?


Japh answers:

I think using the options table would be a little cumbersome, especially with more than a few categories. Using a separate table would allow you to essentially extend the attributes of a category with your own custom ones.

Normally you might add this sort of information into the 'wp_terms_taxonomy' table, but it's best not to mess with core WP stuff, or you might ruin things for automatic upgrades etc (either WP, or your plugin might break).

So I think an extra table would be a more robust option if you were to develop a plugin for this.


Gerasimos Tsiamalos answers:


Indeed. I just thought first that using an extra table would be unnecessary but on a second thought it makes sense. Someone could create more attributes related to the category so yeah. Good point :)


Max answers:

I think that retrieving the date of the oldest post in a category might work fine.

Here is the code:


$args = array('orderby' => 'name', 'order' => 'ASC');

$categories = get_categories($args);

foreach($categories as $category)
$my_query = new WP_Query('category_id='
. $category->cat_ID
. '&showposts=1&orderby=date&order=DESC');

while($my_query->have_posts()) : $my_query->the_post();
echo $category->name . ' '
. get_the_time('d/m/y') . '<br />';