php – How to exclude labels from certain categories in a shortcode?


Good afternoon. There is a shortcode [alltags] that displays ALL site tags on a separate page of the site in alphabetical order with a letter.

function wph_alltags_shortcode($atts, $content) {
$posttags = get_tags();
if($posttags) {
    $output="<dl class="alltags">";
    foreach($posttags as $tag) {
        $l = mb_strtoupper(mb_substr($tag->name,0,1,'UTF-8'),'UTF-8');
        if ($L != $l) {
            if ($L) $output .= '</dd>';
                $L = $l;
                $output .= '<dt>'.$L.'</dt><dd>';
            $output.='<a href="/tag/'.$tag->slug.'">'.$tag->name.'</a> '; 
    $output .= '</dl>';
return $output;

add_shortcode(‘alltags’, ‘wph_alltags_shortcode’);

I need to exclude the display of tags from certain categories of the site, at least from one. I am completely new to PHP. (Please help me with solving this problem. Thank you very much in advance!

mEdvEd 9 months 2022-05-10T06:04:52-05:00 0 Answers 0 views 0

Leave an answer