Skip to content

Instantly share code, notes, and snippets.

@aahan
Last active December 28, 2015 03:09
Show Gist options
  • Select an option

  • Save aahan/7432948 to your computer and use it in GitHub Desktop.

Select an option

Save aahan/7432948 to your computer and use it in GitHub Desktop.
<?php
/*
* Get category from query_var of current page
*
* http://codex.wordpress.org/Function_Reference/get_query_var
* http://codex.wordpress.org/Function_Reference/get_term
* http://codex.wordpress.org/Function_Reference/get_term_by
* http://codex.wordpress.org/Function_Reference/get_category_by_path
* http://codex.wordpress.org/Function_Reference/get_category_by_slug
* http://codex.wordpress.org/Function_Reference/get_the_category
* http://codex.wordpress.org/Function_Reference/get_category
*/
$category = get_query_var( 'category_name' );
$category = get_term_by( 'slug', $category, 'category' );
$category_name = $category->name;
$category_slug = $category->slug; // OR // get_query_var( 'category_name' );
$category_desc = $category->description;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment