Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functions.php文件中获取文章分类链接的get_post_category_link函数逻辑问题 #436

Closed
zhzq97 opened this issue Aug 20, 2024 · 0 comments

Comments

@zhzq97
Copy link

zhzq97 commented Aug 20, 2024

  • 主题版本号:2.8.6
  • WordPress版本:6.6.1
  • PHP版本:7.4
  • 问题阐述:functions.php文件中获取文章分类链接的get_post_category_link函数逻辑问题。
    问题部分:
if (!is_category()) {
        $cate = $cats[0];
    } else {
        $cate = get_category($cat);
    }

这部分内容是判断是否为分类页面,然后返回对应值。但是如果有父分类和子分类的情况下,在父分类页面会显示为父分类的名称和链接,不是真实所在的子分类名称和链接。
原展示效果:
H_0L0@HUG6QDO4%QG}H$P
修改:

$cate = $cats[0];

不需要进行判断,直接获取就可以解决。发布文章时,只需要设置子分类即可。
修改后效果图:
{}I0)V`EPKH0M%KJBGO4C

@zhzq97 zhzq97 added the 待确认问题 等待确认是否是已存在的问题 label Aug 20, 2024
@Licoy Licoy added 优化 已解决 and removed 待确认问题 等待确认是否是已存在的问题 labels Aug 21, 2024
@Licoy Licoy closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants