Answer the question
In order to leave comments, you need to log in
How to disable the display of posts by tag?
Please tell me how to exclude the output of records by tag? I tried several options, in the end it did not work ..
Answer the question
In order to leave comments, you need to log in
Use a function:
after calling
It, it will return an array of objects, something like this:
Array
(
[0] => stdClass Object
(
[term_id] => 4
[name] => tag2
[slug] => tag2
[term_group] => 0
[term_taxonomy_id] => 4
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 7
)
[1] => stdClass Object
(
[term_id] => 7
[name] => tag5
[slug] => tag5
[term_group] => 0
[term_taxonomy_id] => 7
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 6
)
[2] => stdClass Object
(
[term_id] => 16
[name] => tag6
[slug] => tag6
[term_group] => 0
[term_taxonomy_id] => 16
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 2<code lang="php">
</code>
)
)
<?php
$a = true; //Предполагаем что пост это выводим
$t = wp_get_post_tags($post->ID);//получаем все теги для этого поста
foreach($t as $tt) {
//перебираем все теги
if ($tt->name == 'мой тег') {//здесь условие сравнения. В данном случае по имени тега. Можно использовать и другие условия для slug,term_id. Как считаете нужным.
$a =false;
break;
}
}
if ($a == true) {
?>
<div class="post excerpt2">
<?php
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question