To get the random tags of WordPress you just need to make a function like below and save it in your themes/child-themes functions.php file.
Have a look of below code--

function random_tag_abhinesh(){ $a=get_the_title(); //search the tag by the order of first letter of page title ex- page title is A then the tags which is started from letter A
 $a = strtolower($a);
  
   $tags = get_tags(array(
  'hide_empty' => false,
    'orderby' =>'count'
 ));
 shuffle($tags);
  foreach ($tags as $tag ) {
 if(strtolower(substr($tag->name,0,1)) !=$a){
   continue;
     }?>
<a class="link-of-tag" href="<?php echo get_tag_link( $tag->term_id ) ?>">
<div class="name-of-tag"><?php echo $tag->name ?></div></a>

0 comments: