WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The function below is typically used when inside a loop of categories in order to return each category's description. I'm trying to use it to return the individual category's description when viewing a category landing page (mysite/category/somecategory).

How do I pass the equivalent object that represents the category?

On header.php

if(is_archive()) {
//get the category description
echo get_cat_desc(get_query_var( 'category' ))

In functions.php

function get_cat_desc($category){
  $the_description = strip_tags($category->description);
  if(strlen($the_description) > 200 ) 
return  SUBSTR( $the_description,0,STRPOS( $the_description,".",200)+1);
else return  $the_description;

Here is the function where I'm successfully passing in the category object to the function above...

function my_category_index(){
foreach($categories as $category) {echo ce4_get_cat_desc($category);}
share|improve this question
up vote 1 down vote accepted
get_cat_desc(get_category(get_query_var( 'category' )));


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.