RSS

Get current category id and slug

27 Aug

//Check if the page is a category one and display the current category id and slug..

if ( is_category()) {
$cat = get_query_var(‘cat’);
$currentcat = get_category ($cat);
echo ‘current category id is ‘. $yourcat . ‘
‘;
echo ‘current category slug is ‘. $yourcat->slug
}

Advertisement
 

About john martel

Someday I'll fly. Someday I'll soar.
Leave a comment

Posted by on August 27, 2011 in Wordpress

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.