number
(integer) The maximum number of terms to return. Default is to return them all.
http://codex.wordpress.org/Function_Reference/get_terms
So…
$terms = get_terms('new_category',array('number' => 5));
But there is a good chance that some of your terms will never show up. You will get the first five or the last five (in the example) depending on the sort order. You may want something like this instead:
$terms = get_terms('category');
if (!is_wp_error($terms)) {
$pick = ($pick <= count($terms)) ?: count($terms);
$rand_terms = array_rand($terms, $pick);
echo '<ul>';
foreach ($rand_terms as $key => $term) {
$term = $terms[$term];
$term_link = get_term_link( $term );
var_dump($term_link);
if (!is_wp_error($term_link)) {
echo '<li><a href="' . $term_link . '"><div>' . $term->name . '</div></a></li>';
}
}
echo '</ul>';
}
Related Posts:
- Get Posts by Custom Post Type ,Taxonomy, and Term
- How do I list custom taxonomy terms without the links?
- wp_insert_term doesn’t work with custom post type’s taxonomy
- Retrieve single term slug
- Get list of terms of current taxonomy archive for another taxonomy
- Get all taxonomies for all post types
- How to check the terms in single custom post type template
- Issue on Creating Custom Tax Term Dynamically From Another CPT Meta-box On Publish
- How do I display the taxonomy for a custom post type in an array
- Custom Taxonomy Terms in Menu lead to which page?
- How to order taxonomy terms by most recent post?
- Get all posts for custom taxonomy term
- Pages of my taxonomy terms are showing all posts
- Filter Term By Parent Term – Custom Post Type
- Filter By Term Not Working – Custom Post Type
- WordPress add taxonomies/terms list as a menu in archive page
- get_the_term_list() wanting to loop through the returned values
- List custom taxonomy terms
- Display associated taxonomy child name on single CPT page
- Issue On Listing Woocommerce Parent Tag List
- Taxonomy Archive URL + Template
- How to list custom taxonomy terms without the hyperlinks?
- How to conditionally redirect to the post from a taxonomy page?
- How do I check if the user is on a taxonomy term parent, child or grandchild page?
- How do I display the grand child items of a taxonomy term?
- Taxonomies relations
- Is it better to use WordPress Custom Post Types or Taxonomies?
- Display Custom Taxonomy Alphabetically
- Full Custom Post Type List Organised by two Taxonomies
- WordPress Doesn’t Generate Taxonomy Archive
- Suggested Post and Taxonomy structure
- How do I require the specification of term in a custom post type and custom taxonomy?
- Custom Post, set object Taxonomy terms in plugin
- Get terms that contain posts that in turn belong to other terms?
- Custom post with more than one custom taxonomy
- How to get custom posts sub category link
- Custom while loop for hierarchical display of a taxonomy
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Get the taxonomy of a post hierarchically
- Adding custom taxonomy in same menu place with two custom post types
- How to make custom taxonomy into drop down select in a custom metabox
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Display taxonomy terms, child terms and posts in a template
- How to get list of taxonomy slugs ordered parents>childs?
- Use custom walker to add taxonomy terms to main nav menu
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- How do I share categories across multiple post types?
- Add term to custom post type on draft
- Multiple tag cloud filtering
- Get url.com/post_type/taxonomy/term work!
- Displaying custom-taxonomy-terms sorted by parent/child-hierarchy?
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Taxonomy in URL
- Listing all term items alphabetically / sorting loop
- Different Category system needed for the Custom Post Type
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- How to get WordPress term attached to the Post?
- Query posts with double taxonomy
- Output terms for custom post types
- Adding predefined terms to a taxonomy
- How to Set Taxonomy Object Description?
- Custom select query for taxonomies that have posts categorized in another taxonomy
- Get parent category id from child category page for custom taxonomy
- Custom Taxonomy Is Being Pulled into a Page, But It Doesn’t Have A Hyperlink
- Querying two taxonomies with tax_query not woking
- Rename a slug label
- Hide specific taxonomies from a taxonomy list using ‘get_object_taxonomies’
- How to get only child terms from a custom taxonomy of current post type?
- Custom query – get_the_terms not work
- Custom taxonomy (categories) on custom post type return no results
- Variable not working in WP_Query
- Hide meta box for everything BUT a certain custom post type
- get_category_link() for custom post type does not include custom slug rewrite?
- How to Display Posts From Category Within a Custom Taxonomy?
- Custom Post Types Archives and Single Pages not showing custom taxonomy data
- Targeting categories in custom fields
- How can I create an automatic drop down menu with my tags?
- How to define a term for custom taxonomy
- List custom taxonomy as navigation – taxonomy pages with all it’s posts?
- Alphabetically sort a taxonomy.php template by post title
- Shared terms between taxonomies
- Custom Post Types not queried in Custom Taxonomy archives or Native archives
- Get taxonomy singular name instead of taxonomy slug inside $taxonomy query
- Get terms of a post but only if they’re also the child of a specific term
- Show Taxonomies with admin area for custom post type?
- The Difference Between Categories and Tags and Taxonomies and Terms
- How to get dropdown instance value in WordPress custom Widget
- Get taxonomy term by slug in post on archive page
- Custom taxonomy template list not working (404)
- Use the custom post type archive for taxonomies?
- Rewrite custom post type with taxonomy
- custom hierarchical taxonomy and custom post type list contains surplus posts
- WordPress multisite – is it possible to have different taxonomies for each site?
- How to display custom taxonomy term meta on custom post type
- My custom taxonomy is only displaying 1 of 3 terms
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Query custom post types & Taxonomies and list them in a table on a page
- Taxonomy template page not working
- how to count the current posts terms