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
- How to display random users with avatars
- Creating a table from shortcode avoiding wpautop for each row
- Stripping shortcode from custom excerpt function
- how to create shortcode in wordpress
- Php string not working in WordPress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar)
- Add class to Categories Widget
- How to Acheive the custom woocommerce category template
- Formatting post content to exclude gallery
- Shortcode with custom content attribute?
- Shortcode to insert menu in page body?
- How to add a rel attribute to images that contains their categories?
- Displaying a random user with a shortcode
- Assign category using custom field?
- Passing HTML in WordPress Shortcode arguments
- Function to show only first instance of shortcode
- Changing post category from dropdown
- Custom Shortcode, functions PHP WP_Query loop
- Super simple shortcode not working
- Attach parent category template to all subcategories
- Display gallery on top before content
- List child pages of specific page using shortcode
- exclude a category from a search on a specific page
- Insert HTML inside link in a walker
- How to extract the variables out from “add_shortcode” function?
- How to get specified parent page title in my function
- Unset Category if other Category is unset during post transition
- Select pages by category
- Display post shortcode content in the sidebar?
- How to get the index number of the posts?
- Using shortcode content with nested shortcode
- Custom shortcodes not inserting into visual composer columns
- How to filter $content in shortcode function
- Adding a colorbutton in tinymce dialog with current api
- Display gallery on bottom after content
- Excerpts are not displayed by a shortcode on category pages
- WordPress Shortcode function display outside of widget
- Get category URL for current post
- check if the user is owner of current page
- shortcode help require
- allow only one post in specific category
- Use html inside shortcode function
- How to obtain the recent posts without their content in an efficient way?
- Running script based on Category
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- Function shortcode – Set Parameter
- Using multiple line variable inside a function?
- Echoing function into WordPress NextGen gallery
- How to echo the value of an array element using a function via a shortcode
- 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
- Image loading function not working on archive.php template
- Specify multiple categories for custom post template – FATAL ERROR
- How to create shortcode with html and php content?
- Shortcode question
- Can I include a custom PHP function in a WordPress function?
- How add body_class from wp_termmeta
- Shortcode to get featured image of specific id post
- How to load several hierarchical categories from functions.php
- Problem with shortcode inside a shortcode
- Get slug of current category in functions.php
- Need help making a short code work
- Load templates, pass arguments, and render output from functions.php
- Passing function arguments via a shortcode
- Probleme shortcode with list author
- Last updated posts shortcode in functions.php
- Shortcode to output category description by passing ID
- Help using ShortCodes to style whole chunks of the post
- how to remove a tag in the_category function
- Why is the term of my current page not returning a slug?
- Graphic before title – Specific Category
- HowTo: Add wrapper to columns shortcode?
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Custom shortcode with do_shortcode and substr
- Display List of Categories Within a Custom Taxonomy
- Can I use a function to return HTML and the result of another function?
- WordPress shortcode Issue!
- Problem in shortcode outputting content
- Expanding a function to call a plugin or show a link
- Get category id for a custom category and display it in a class
- Trying to the deduce shortcode from a function
- Pull random comment from specific post, display on homepage with shortcode
- Run function from parent on child site
- Shortcode Variations?
- Custom shortcode not being included in content paragraph [duplicate]
- Creating mixture of shortcodes to use in the visual/text editor
- PHP error in shortcode [closed]
- Removing all Category pages with one exception
- Display terms on product page with shotrcode
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Get category of post inside save_post hook