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 want to create a page that lists all the Custom Taxonomies, with each item linking to a page that will list all the terms in a given taxonomy.

I can produce a list of taxonomies using this

 <?php 
$args=array(
  'public'   => true,
  '_builtin' => false

); 
$output = 'names'; // or objects
$operator = 'and'; // 'and' or 'or'
$taxonomies=get_taxonomies($args,$output,$operator); 
if  ($taxonomies) {
  foreach ($taxonomies  as $taxonomy ) {
    echo '<p>'. $taxonomy. '</p>' ;
  }
}
?>

But of course no links.

Looking at the codex there is very little information on the parameters - at least for neophyte like myself.

Any suggestions on how to output a link for each custom taxonomy?

Thanks

share|improve this question
2  
Taxonomies don't have archive pages like that, so there's nothing really to link to in this case. –  chrisguitarguy Feb 24 '12 at 0:16

1 Answer 1

up vote 0 down vote accepted

Once you get $taxonomy you can perform further logic:

$tax = get_taxonomy( $taxonomy );

if( isset( $tax->has_archive ) && $tax->has_archive == true ) {
    // do output. archive will be wordpress_url + $taxonomy->name
    ?>
    <p>
        <a href="<?php echo site_url( $taxonomy->name ); ?>">
            <?php echo $tax->labels->name; ?>
        </a>
    </p>
    <?php
}

This is untested, but you get the idea.

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.