首页 > 解决方案 > 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,但没有任何效果

在 localhost 上工作时查看 url 的屏幕截图 在此处输入图像描述

我究竟做错了什么?

标签: phpwordpress

解决方案


我用这个解决了这个问题 <?php echo get_the_category_list(', ');?>


推荐阅读