Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.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 如何输出带有额外标记的wp_列表_类别_Php_Wordpress_Loops - Fatal编程技术网

Php 如何输出带有额外标记的wp_列表_类别

Php 如何输出带有额外标记的wp_列表_类别,php,wordpress,loops,Php,Wordpress,Loops,我目前正在使用下面的脚本以无序列表的形式输出我的所有wordpress类别。如何使输出具有额外的标记 <ul><?php wp_list_categories('title_li&show_count=1');?></ul> 例如: <ul> <li>Category 1 &rsaquo;</li> <li>Category 2 &rsaquo;</li> </

我目前正在使用下面的脚本以无序列表的形式输出我的所有wordpress类别。如何使输出具有额外的标记

<ul><?php wp_list_categories('title_li&show_count=1');?></ul>
    例如:

    <ul>
    <li>Category 1 &rsaquo;</li> 
    <li>Category 2 &rsaquo;</li> 
    </ul>
    
    • 第一类&rsaquo
    • 第2类&rsaquo
    而不是

    <ul>
    <li>Category 1</li> 
    <li>Category 2</li> 
    </ul>
    
    • 第一类
    • 第2类
    编辑:在Obmerk Kronen的帮助下将其更改为以下内容:

    $args = array(
      'orderby' => 'name',
      'order' => 'ASC',
      'number' => 20, // how many categories
      );
    $categories = get_categories($args);
      foreach($categories as $category) { 
        echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>&rsaquo;</li>';
        } 
    
    $args=array(
    'orderby'=>'name',
    “订单”=>“ASC”,
    'number'=>20,//有多少类别
    );
    $categories=get_categories($args);
    foreach($categories作为$category){
    回音“
  • ; }
    有两种方法可以轻松完成

    1-使用


    查看其他字符以及如何使用它们

    谢谢您,先生!但是,您忘记了order数组旁边的逗号。此外,>asci符号将放置在下一水平线上,而不是类别名称旁边。我已经纠正了这两件事,请看我的问题编辑。你知道如何在每个类别旁边计算类别数吗?如果您可以编辑您的答案,那么我可以将其标记为接受。Merry Xmascorrection:>下一水平线上的asci符号在您的解决方案中是正确的,我问错了。我一问就改了,伙计。。在我的回答中,你有一个答案。你读过吗??投反对票有点可笑。你只需要阅读法典的链接。
    $args = array(
      'orderby' => 'name',
      'order' => 'ASC',
      'number' => 20 // how many categories
      );
    $categories = get_categories($args);
      foreach($categories as $category) { 
        echo '<li><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></li>&rsaquo;';
        } 
    
    .my_class li:after{ content:" \203A";}