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 get all taxonomies of a post type?
- How do I append multiple taxonomies to the URL?
- Display current taxonomy term when inside custom post type
- Get term slug of current post
- wp_get_object_terms(): count relative to passed IDs?
- Count posts that have specific taxonomy term attached
- Taxonomy archives based on Custom Post Type
- Get the ‘slug’ of a custom taxonomy
- Custom Metabox with Taxonomy Dropdown – Saving Issue
- Maintaining strict one-to-one association between terms and custom posts
- If on term-page -> get the current term?
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- Include custom post type in “all posts”
- Creating a function that receives the taxonomy terms that have been changed in a custom post type
- How do I provide a “show all posts” link in a paginated term archive?
- get_post_meta returns empty array for terms
- Custom Post Type Archive Page Filtering
- Get posts by querying taxonomy and certain terms of the taxonomy?
- Custom Taxonomy back-end customizations
- Post count by month of taxonmy term
- How to conditionally redirect to the post from a taxonomy page?
- Suggested Post and Taxonomy structure
- Custom while loop for hierarchical display of a taxonomy
- Use custom walker to add taxonomy terms to main nav menu
- How do I share categories across multiple post types?
- Add term to custom post type on draft
- Listing all term items alphabetically / sorting loop
- Output terms for custom post types
- Custom select query for taxonomies that have posts categorized in another taxonomy
- Get parent category id from child category page for custom taxonomy
- How to get only child terms from a custom taxonomy of current post type?
- Hide meta box for everything BUT a certain custom post type
- Custom Post Types Archives and Single Pages not showing custom taxonomy data
- How can I create an automatic drop down menu with my tags?
- 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
- Custom taxonomy template list not working (404)
- Use the custom post type archive for taxonomies?
- How to display custom taxonomy term meta on custom post type
- Taxonomy template page not working
- does wp_insert_term link the term to a certain post ID?
- Get posts by category name
- Grab all Custom Posts by multiple taxonomies and terms
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Order posts by taxonomy terms
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- How to display custom taxonomy term specific post?
- Define multiple prefixes for custom post type
- How to associate custom taxonomy terms with custom post type?
- get_queried_object not work in taxonomy page
- Taxonomies are not showing in the category dropdown
- get_the_terms child terms for current post/custom post only
- Change custom post taxonomy values from front-end
- List posts that have the current url taxonomy
- How to transfer categories (default) to custom taxonomy?
- Custom Taxonomy – fields
- Display title of all custom posts from same taxonomy term on a custom post template
- wordpress does not see the correct custom taxonomy hierarchy
- Get category list & taxonomy list from different post type using post id?
- How to get all posts related to a taxonomy?
- How to get all posts assigned to a taxonomy term only?
- Custom taxonomy- only output relevant terms
- How to pass taxonomy terms to WP_Query along with $args?
- How to create TEMPLATES for TAXONOMIES? What I have to change in this code?
- Custom Post Status & Taxonomies
- Create an additional template page for every term taxonomy
- Prevent repetitive terms in get_the_term_list
- Displaying taxonomy icon outside archive page
- Taxonomy Grid Archive Help?
- Show taxonomies from specific CPT
- Custom post type URL returns 404 error page
- List a custom post type’s posts ordered by nested custom taxonomy
- Author template – separate custom post type by custom taxonomy term for $curauth
- See the process of creating a taxonomy and tell me where I made a mistake
- How to manage a bookstore
- Get all terms assigned to a post from different taxonomies
- How to add to taxonomies to a post type
- Filtering custom post types using category taxonomy
- How to use wp_set_object_terms depending on page ID?