Answer the question
In order to leave comments, you need to log in
How to disable the display of tags with id 2 and 4?
There is a code that displays the tags as a list. The question is, how to disable the output of tags with id 2 and 4?
<?php
$tags = get_tags( 'orderby=name&order=ASC' );
$capital = '';
$i = 0;
$cols_number = 1;
$cut = ceil( count( $tags ) / $cols_number );
$cutter = $cut;
$letter_i = 0;
$output = '<div class="columnia">';
foreach ( $tags as $tag ) {
$i ++;
$firstletter = mb_substr( $tag->name, 0, 1 );
$firstletter = mb_strtoupper($firstletter);
if ( $firstletter != $capital ) {
$letter_i ++;
if ( $letter_i != 1 ) {
$output .= '</p>';
}
if ( $i > $cutter ) {
$output .= '</div><div class="columnia">';
$cutter = $cutter + $cut;
}
$capital = $firstletter;
}
$term = get_term_by( 'id', (int) $tag->term_id, 'post_tag' );
$output .= '<p class="p00"><a href="' . get_term_link( (int) $tag->term_id, 'post_tag' ) . '">' . $tag->name . '</a>';
}
echo $output . '</p></div>';
?>
Answer the question
In order to leave comments, you need to log in
Approximately the principle is
foreach ( $tags as $tag ) {
if($tag->term_id == 1 || $tag->term_id == 2)
continue;
//далее ваш код
}
I don’t know if I understood the essence of the task correctly, but what if at the very beginning of the for loop we write, for example, like this:
===
...
foreach ( $tags as $tag ) {
if (in_array($tag->id, array(2,4)))
...
===
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question