terms – How to get tags only with custom meta field and display them randomly?

Question

I’m trying to have a function to display only the tags with custom meta field tax_image_url_universal and display them randomly, which means when page reloads different tags to be displayed.

Currently I have the following to display random tags, but I don’t know how to restrict them first with the custom meta field.
Thanks for any advice.

function wpll_get_popular_nodes() {
$args = array('exclude' => '36 17'); 
$alltags = get_tags( $args );
shuffle($alltags);
$count=0;
if($alltags) {
    foreach($alltags as $tag) {
        $count++;
        echo '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a>';
        if( $count >4 ) break;
    }
}

}

0
ooneland 2 months 2022-11-30T16:01:32-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse