0

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

1
  • 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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.