Saturday, May 21, 2016

WordPress get current category id

To the the Category ID on Current active page in WordPress use the following code.

<?php
$categories = get_the_category();
$category_id = $categories[0]->cat_ID;
echo category_id;
?>


Your Category ID will be present in category_id.

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...