php - Wordpress 类别链接重定向到未分类而不是该类别
问题描述
wordpress 类别链接重定向到未分类.. 在这种情况下进行测试,因为我将未分类的类别名称更改为测试而不是该特定类别
这是我的代码
<?php while(have_posts()){
the_post();
?>
<article class="blog_item">
<div class="blog_item_img">
<img src="<?php the_post_thumbnail_url('blogHome'); ?>" alt="fastinfo">
<span class="ribbon3 text-center"><a href=""><?php the_time('n-j-y');//the_date('d-m-y'); ?></a></span>
</div><!--blog_item_img-->
<div class="blog_details clearfix">
<a href="<?php the_permalink(); ?>" class="blog-post-heading">
<h2><?php the_title(); ?></h2>
</a>
<p><?php echo wp_trim_words(get_the_excerpt(),29);?></p>
<ul class="blog-info-link float-left mt-2">
<?php
$category = get_the_category( $id );
$category_link = get_category_link($category);
//echo $category[0]->cat_name;
?>
<li><a href="<?php echo esc_url($category_link);?>"><i class="fa fa-user"></i><?php echo $category[0]->cat_name;?></a></li>
<li><a href=""><i class="fa fa-comments"></i><?php comments_number( '0', '1', '%' ); ?>.</a></li>
</ul>
<a href="<?php the_permalink(); ?>" class="btn btn-spa float-right">Read More</a>
</div><!--blog_details-->
</article><!--blog_item-->
<?php } wp_reset_postdata();?>
我有archive.php ..尝试制作category.php,但没有任何效果
我究竟做错了什么?
解决方案
我用这个解决了这个问题
<?php echo get_the_category_list(', ');?>
推荐阅读
- javascript - 如何访问内容类型字段中的字段?
- maven - Intellij IDEA 不尊重 Maven 设置
- java - BeanIo 无法读取 xml 中的特殊字符
- python - 如何在字段比较操作中,在列类型SqlAlchemy(或其他类)中实现值转换?
- r - 为什么我会收到关于奇异拟合的警告,尽管随机效应方差未估计为零,相关性也未估计为 +/- 1?
- git - Git 克隆仅适用于 git:// 而不适用于 https://
- excel - 使用 Excel::download() 方法将 excel 列设置为自动
- angular - 使用 MSAL Angular 包装器在 Ionic 4 中处理来自 Azure AD 的回调
- sql - 选择与结果匹配的 WHERE 子句
- c++ - 如何在单链表的开头插入