Try this code:
function these_rand_tax1()
{
$max = 8; //number of categories to display
$taxonomy = 'baumaschinen_cat';
$terms = get_terms('taxonomy=' . $taxonomy . '&orderby=name&order=ASC&hide_empty=0');
$terms = (array)$terms;
// Random order
shuffle($terms);
// Get first $max items
$terms = array_slice($terms, 0, $max);
// Sort by name
usort($terms, function ($a, $b)
{
return strcasecmp($a->name, $b->name);
});
// Echo random terms sorted alphabetically
if ($terms)
{
foreach ($terms as $term)
{
echo '<p><a href="' . get_term_link($term['slug'], $taxonomy) . '" title="' . sprintf(__(" View all posts in %s"), $term['name']) . '" ' . '>' . $term['name'] . '</a></p> ';
}
}
}
Related Posts:
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Possible to display shortcode based on the category?
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Get Attachment Category Name
- Taxonomy On Index Page
- Show Primary Category first when I display post categories
- How do I hide or remove ‘Category’ from wordpress breadcrumbs
- Ordering posts by publish date not working?
- How to get the index number of the posts?
- Using shortcode content with nested shortcode
- Move ‘current-menu-item’ class on #adminmenu li from Posts to Pages for Taxonomy Edit Screen
- How can I make a widget shortcode to control all the widgets?
- Custom shortcodes not inserting into visual composer columns
- How to filter $content in shortcode function
- Setting youtube size in functions.php
- Categories as main menu items and subcategories as nested lists
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- Display gallery on bottom after content
- Add button to kitchen sink toggle
- Excerpts are not displayed by a shortcode on category pages
- Redirect to another page using contact form 7? [closed]
- WordPress Shortcode function display outside of widget
- Get category URL for current post
- check if the user is owner of current page
- Need help “sanitizing” a custom function that pulls category slug into body class
- shortcode help require
- allow only one post in specific category
- Optimizing a WordPress site
- Help With Creating Shortcode
- Use html inside shortcode function
- How to obtain the recent posts without their content in an efficient way?
- Setting a default text for excerpts of a particular category
- Running script based on Category
- Remove a category from a post when saving a new post
- How to fix get_the_category function returning incorrect slug?
- Return category name with & Ampersand doesnt work
- Shotcode argument issues
- Shortcode parse error – wrong syntax
- Exclude category from shortcode
- wp_nonce_field is breaking form for reasons unknown
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- get_pages() Returns Only One Item
- Function shortcode – Set Parameter
- add slug beside name in Admin Category Checklists
- Adding an option to a shortcode
- How to use author meta in shortcode?
- Using multiple line variable inside a function?
- Testing for a shortcode using a function. 404 page throwing PHP Notice
- Use a shortcode to display custom meta box contents
- Echoing function into WordPress NextGen gallery
- Output loop to function return?
- How to echo the value of an array element using a function via a shortcode
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- Wp-query Order By problem
- Access category within rss2_head hook?
- issue with if/elseif in_array inside foreach loop display only one post
- Randomizing wp_tag_cloud() in child theme
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- add_filter to specific WooCommerce Category
- How to rewrite wordpress search to work on specific category
- Woocommerce checkout field
- How to include any template using Shortcode fuction?
- Image loading function not working on archive.php template
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- Exclude Category ID in function
- Problem with calling custom function in a foreach loop
- Need to convert image url to a Base_64 data url with wordpress function..
- dynamic site link for future migration in echo do_shortcode()
- Specify multiple categories for custom post template – FATAL ERROR
- How to create shortcode with html and php content?
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Shortcode question
- “All posts” in the category widget
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- How add body_class from wp_termmeta
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- How to load several hierarchical categories from functions.php
- Shortcode of a function
- show all the posts thumbnails
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- WordPress Categories: Function using custom SQL to return array of specific category IDs
- Problem with shortcode inside a shortcode
- Display ACF category image on archive and single template files
- Get slug of current category in functions.php
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Need help making a short code work
- Add custom taxonomy using JS in post editor
- How to divide Subcategories into pages of parent category wordpress
- Using One Function To Create Two Different Shortcodes
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- get category in list of posts // shortcode for custom related posts