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.

I have created a custom post type and custom category for that post. There are some categories in that custom category. now I want to get the links for each category I have in that list.

I just want to get the link form its tag id. how can I do that

share|improve this question
    
wp_list_categories –  soulseekah Mar 14 '12 at 13:04

2 Answers 2

As the other's mentioned, wp_list_categories will work if you you want to do a list of things (just like wp_list_pages does for pages).

If you specifically want the link (URL), you can use get_term_link. If you just have the term ID, it would look something like this.

<?php
$term_id = some_function_that_returns_term_id();
$term_link = get_term_link($term_id, 'your_custom_taxonomy');

if (!is_wp_error($term_link)) {
    // do stuff with $term_link
}

If you have the whole term object -- for example the object returned by get_term_by -- you can pass the entire object in as the first argument of get_term_link and you're done.

<?php
$term = get_term_by('id', $some_term_id, 'your_custom_taxonomy');

$term_link = false;
if ($term) {
    $term_link = get_term_link($term);
}

if (!is_wp_error($term_link)) {
    // do stuff with $term_link
}
share|improve this answer

wp_list_categories('taxonomy=custom_tax'); custom_tax is custom taxonomy name

share|improve this answer

Your Answer

 
discard

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.