Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Listing custom taxonomy terms in WordPress

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 123
    Comment on it

    Most used concept of the WordPress is custom taxonomies as well as custom post. We can build our own custom post as well as taxonomies.
    If you want to list terms of your custom taxonomies then you can simply use function named get_terms which takes two arguments. First one is array of the taxomonies which you want to list and array of different arguments like order,slug,orderby,search etc. Let's take an simple example.

    <?php
    //list terms in a given taxonomy
    $taxonomy = 'smartcities';
    $smart_terms = get_terms($taxonomy);
    ?>
    <ul>
    <?php
    foreach ($smart_;terms as $smart_term) {
    echo '<li>' . '<a href="' . esc_attr(get_term_link($smart_erm, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $smart_term->name ) . '" ' . '>' . $smart_term->name.'</a></li>';
    }
    ?>
    </ul>
    

    In above example we are fetching terms of custom taxonomies named smartcities and displaying in listing.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: