我目前正在使用以下脚本在无序列表中输出我的所有wordpress类别.如何使用额外标记获得输出?
例如:
代替
编辑:在Obmerk Kronen的帮助下将其更改为以下内容:
$args = array( 'orderby' => 'name', 'order' => 'ASC', 'number' => 20, // how many categories ); $categories = get_categories($args); foreach($categories as $category) { echo '
Obmerk Krone.. 8
有两种方法可以轻松完成.
1 - 使用get_categories()
$args = array( 'orderby' => 'name', 'order' => 'ASC', 'number' => 20 // how many categories ); $categories = get_categories($args); foreach($categories as $category) { echo '
2 - 使用与您在问题中发布的代码相同的css :after
选择器
.my_class li:after{ content:" \203A";}
请参阅其他字符以及如何在此处使用它们
有两种方法可以轻松完成.
1 - 使用get_categories()
$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>›'; }
2 - 使用与您在问题中发布的代码相同的css :after
选择器
.my_class li:after{ content:" \203A";}
请参阅其他字符以及如何在此处使用它们