Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.


This helped me:

$cat_name = 'onde-encontrar';
$category = get_category_by_slug( $cat_name );
$taxonomies = array( 'category' );
$args = array( 'parent' => $category->term_id );
$terms = get_terms( $taxonomies, $args );
foreach ( $terms as $term ){
echo "<a title='title' href='www.era420/category/{$cat_name}/#{$term->term_id}'>{$term->name}</a>";

But this doesn't print subcategories, and I want to print subcategories too.

Any suggestions?


I have this code that works perfectly for what I want, but I want the link that shows the wp_list_categories, is the id of the category and not the permalink. For desire that when you click on the category it scroll down and does not change the main page ...

My code:

$category = get_category_by_slug( 'onde-encontrar' );

What it shows me:

<a title="title" href="www.era420/category/onde-encontrar/sao-paulo/">São Paulo</a>

But I need:

 <a title="title" href="www.era420/category/onde-encontrar/#33">São Paulo</a>

something like that.

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.