Pin It
Pages Menu
Categories Menu

Posted by in Wordpress Tutorials | 0 Comments

WP e-Commerce: Get Category Slug By Category ID

If you’re using WP e-Commerce plugin, you might find it tricky to get a category slug by that category ID. Here I’ll show you how you can get a category slug by category ID.


You might find these useful

For this purpose, we’ll use WordPress function get_term(). This function is used to all term data from database or apply filters to a term object. You can read full documentation here. See the code below:

  //Assign WP e-Commerce's category id to a variable
  $categoryID = 15;
  $term = get_term($categoryID, 'wpsc_product_category');
  echo $term->slug;

Post a Reply

Your email address will not be published. Required fields are marked *