Hi @correliatt,
As i check the official docs of WordPress Read Here . It does not support random in orderby. To get normal list you can use below code
function get_all_taxonomies(){
$terms = get_terms(
[
'taxonomy' => 'directors',
'hide_empty' => false,
]
);
if ( count( $terms ) ) {
foreach ( $terms as $term ) {
?>
<li>
<a href="<?php echo esc_url( get_term_link( $term ) ); ?>">
<?php echo esc_html( $term->name ); ?>
</a>
</li>
<?php
}
}
}
add_shortcode( 'show_term_list', 'get_all_taxonomies' );
If you want the terms in random order, you could apply shuffle()
to the array of terms before they are output in a loop.
Also, you must not generate output from a shortcode callback. Instead, all output needs to be collected into a single variable which is then returned to WP. WP will then echo out the returned string at the appropriate place. Failure to do this will cause your shortcode output to be in the wrong place on the page.