the_category ( $separator = '', $parents = '', $post_id = false ) Parameters: (string) separator Optional. Separator between the categories. By default, the links are placed in an unordered list. An empty string
<?phpforeach((get_the_category())as$category){echo $category->name."";}?>
Category: <?php the_category(' > ','single'); ?> | <?php the_time('M.d.Y');?> | <?php the_tags('Tags: ',', ',''); ?> 显示效果如下 当然你也可以输出不带链接的分类名称 1 2 3 <?phpforeach((get_the_category())as$category){ echo$category->name.""; }?> 还可以这样...
the_category(', '); echo''; ?> 这种方法可以帮助您在样式上进行更灵活的操控,方便后续的CSS样式调整。 在实际应用中,the_category()函数经常用于博客文章、新闻网站、电子商务平台等各种类型的WordPress网站中,以提供清晰的内容分组。您可以利用这个功能增强网站的可导航性,让访客能够快速找到感兴趣的内容。除此...
the_category – 这个函数用来显示分配给文章的一个或多个类别。它需要几个参数,允许自定义输出,如多个类别之间的分隔符,以及是否链接到类别存档页面。 以HTML列表或自定义格式显示一个文章的类别列表。 function the_category( $separator = '', $parents = '', $post_id = false ) { echo get_the_...
› the_category ( $separator = '', $parents = '', $post_id = false ) Parameters: (3) (string) $separator Optional. Separator between the categories. By default, the links are placed in an unordered list. An empty string will result in the default behavior. Required: No Default: (...
the_category()函数使用方法解析 我们知道是wordpress调用分类的函数,它和the_tags()调用tag标签有点类似,怎么使用呢?随ytkah一起来看看 <?phpthe_category($separator,$parents,$post_id);?>$separator 指定间隔符号; $parents 分类显示方式,两个值multiple和single;multiple值显示所有分类,single只显示指定文章ID的...
get_the_category是一个WordPress函数,用于获取当前文章的分类信息。它返回一个包含当前文章所属分类的数组。 在使用get_the_category函数时,如果返回错误的类别,可能有以下几个原因: 文章没有被分配到任何分类:在WordPress中,文章需要被分配到一个或多个分类才能使用get_the_category函数获取到分类信息。如果文章没有...
$category = get_the_category(); if($category[0]){ echo ‘term_id ).'”>’.$category[0]->cat_name.'’; } ?> 获取指定文章编号的类别信息 <?php global $post; $categories = get_the_category($post->ID); var_dump($categories); ?> 返回对象的成员 cat_ID 类别...
get_the_category() 特定于分类:`get_the_category()` 函数专门用于获取文章的分类(category)。它返回一个包含所有分类对象的数组。 简单使用:如果你只关心标准的WordPress分类,这个函数相对简单易用。 局限性:它只能用于获取分类,不支持自定义分类法(taxonomy)。