wordpress主题制作时调用分类链接的方法
- 时间:2020-05-22 15:47:15
- 分类:网络文摘
- 阅读:128 次
对于杂志(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
How to Make Money from Blogging as a Small Business 6 Reasons Why Your WordPress Blog Is Getting Hacked When to Revise Your Content Marketing Strategy How To Develop Copywriting Skills To Engage Your Blog Readers Five Tips to Lower Your Tax Bill in 2020 Bruteforce Algorithm to Compute the Maxmium Powerful Digit Sum u 4 Frequently Discussed SEO Myths Exposed 3 Reasons Why Graphic Designers Need to Self-Promote through Ins How to Split a String in C++? The Best Instagram Feed WordPress Plugins to Use
- 评论列表
-
- 添加评论