wordpress主题制作时调用分类链接的方法
- 时间:2020-05-22 15:47:15
- 分类:网络文摘
- 阅读:151 次
对于杂志(CMS)类的wordpress主题而言,通常以多分类列表形式来展现网站首页内容,制作时需要在wordpress主题合适位置添加各分类归档页面链接的按钮,下面介绍两段代码,分别通过分类别名、分类ID两种wordpress技巧帮你快速实现分类链接的获取。
代码一:通过分类别名调用wordpress分类链接。
- <?php
- $cat=get_category_by_slug('wordpress');
- $cat_links=get_category_link($cat->term_id);
- ?>
- <a href="http://uuxn.com/wordpress-theme-call-category-links/<?php echo $cat_links; ?>" title="<?php echo $cat->name; ?>">更多</a>
代码二:通过分类 ID 调用Wordpress分类链接。
- <?php
- $cat=get_term_by('id', 12, 'category');
- $cat_links=get_category_link($cat->term_id);
- ?>
- <a href="http://uuxn.com/wordpress-theme-call-category-links/<?php echo $cat_links; ?>" title="<?php echo $cat->name; ?>">更多</a>
代码参考:
http://codex.wordpress.org/Function_Reference/get_category_by_slug
http://codex.wordpress.org/Function_Reference/get_term_by
C++ Algorithms to Find Pair of Sum Given a Collection of Numbers How to Implement strStr() function in C++? How to Check Valid Word Abbreviation in C++? CloudFlare Enterprise Plan Overview Powerful Integers by Bruteforce Algorithm using C++ How to Check if Any Three Points can Make a Triangle? How to Convert Set to Vector in C++? Peeple App Embodies the Worst of Social Media 10 Best Writing Quotes for Bloggers Will Dorsey be Twitter’s Next CEO?
- 评论列表
-
- 添加评论