Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 删除此foreach循环中的数组元素_Php_Arrays_Wordpress_Foreach - Fatal编程技术网

Php 删除此foreach循环中的数组元素

Php 删除此foreach循环中的数组元素,php,arrays,wordpress,foreach,Php,Arrays,Wordpress,Foreach,我在Wordpress中使用了这个代码来列出标签和它们被使用的次数。这是密码 <?php $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') ); foreach ( (array) $tags as $tag ) { ?> <li class="list-group-item"> <span class="badge"><?php echo $tag->co

我在Wordpress中使用了这个代码来列出标签和它们被使用的次数。这是密码

<?php
$tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
foreach ( (array) $tags as $tag ) { ?>
<li class="list-group-item">
<span class="badge"><?php echo $tag->count; ?></span>
<?php echo $tag->name; ?>
</li>
<?php }
?>

  • 结果如下:


    所以我想从列表中删除标记“动物”。我一直在寻找其他问题,但我无法解决我的问题。谢谢你的回答

    您可以按以下方式更新代码:

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name == "Animals" ) { continue; }
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php }
    ?>
    
    
    

  • 您可以按以下方式更新代码:

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name == "Animals" ) { continue; }
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php }
    ?>
    
    
    

  • 您可以按以下方式更新代码:

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name == "Animals" ) { continue; }
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php }
    ?>
    
    
    

  • 您可以按以下方式更新代码:

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name == "Animals" ) { continue; }
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php }
    ?>
    
    
    

  • 使用
    排除
    参数作为
    获取标签()。在我的示例中,我将术语ID设置为5;请确保将其替换为正确的值

    exclude
    也可以是一个数组,允许您排除多个标记

    更改:

    $tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) );
    
    致:


    使用
    get_tags()
    exclude
    参数。在我的示例中,我将术语ID设置为5;请确保将其替换为正确的值

    exclude
    也可以是一个数组,允许您排除多个标记

    更改:

    $tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) );
    
    致:


    使用
    get_tags()
    exclude
    参数。在我的示例中,我将术语ID设置为5;请确保将其替换为正确的值

    exclude
    也可以是一个数组,允许您排除多个标记

    更改:

    $tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) );
    
    致:


    使用
    get_tags()
    exclude
    参数。在我的示例中,我将术语ID设置为5;请确保将其替换为正确的值

    exclude
    也可以是一个数组,允许您排除多个标记

    更改:

    $tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) );
    
    致:

    使用下列内容

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name != "Animals" ) {
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php 
      }
    }
    ?>
    
    
    
  • 使用以下命令

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name != "Animals" ) {
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php 
      }
    }
    ?>
    
    
    
  • 使用以下命令

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name != "Animals" ) {
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php 
      }
    }
    ?>
    
    
    
  • 使用以下命令

    <?php
    $tags = get_tags( array('orderby' => 'count', 'order' => 'DESC') );
    foreach ( (array) $tags as $tag ) { 
      if ($tag->name != "Animals" ) {
    ?>
    <li class="list-group-item">
    <span class="badge"><?php echo $tag->count; ?></span>
    <?php echo $tag->name; ?>
    </li>
    <?php 
      }
    }
    ?>
    
    
    

  • 给定WordPress,这是最好的解决方案。给定WordPress,这是最好的解决方案。给定WordPress,这是最好的解决方案。给定WordPress,这是最好的解决方案。很好!另一方面,如何仅显示所需的标记?例如,我有很多标记,但我只想显示'Tech'和'News'@CristianTirado如果你只想显示一组特定的标记,你应该使用include参数。看,只需使用include而不是exclude。这很好!另一方面,如何仅显示所需的标记?例如,我有很多标记,但我只想显示'Tech'和'News'@CristianTirado如果你只想显示一组特定的标记,你应该使用include参数。看,只需使用include而不是exclude。这很好!另一方面,如何仅显示所需的标记?例如,我有很多标记,但我只想显示'Tech'和'News'@CristianTirado如果你只想显示一组特定的标记,你应该使用include参数。看,只需使用include而不是exclude。这很好!另一方面,如何仅显示所需的标记?例如,我有很多标记,但我只想显示'Tech'和'News'@CristianTirado如果你只想显示一组特定的标记,你应该使用include参数。请看,只需使用include而不是exclude。