Support » Themes and Templates » Display subcategory slug

  • Hi!
    I’m building a portfolio site with many categories. One of them have subcategories.
    (Portfolio -> Packaging, Graphic, Handmade, …)

    I need to display only the subcategory slug in my template. I used this code:

    <?php echo get_category(get_query_var('cat'))->slug; ?>

    but the result is “portfolio”. How can I display only “handmade”?

    Thanks for any help 🙂

Viewing 1 replies (of 1 total)
  • I found the solution!

    <?php $args = array('parent' => 13);
    $categories = get_categories( $args );
    foreach($categories as $category) {
        echo $category->slug.' ';
    } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Display subcategory slug’ is closed to new replies.