网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > WordPress
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 112.87.85.4
Old 2015-06-14, 05:32 AM
Jaime Jaime is offline
初级会员
 
Join Date: 2006-10-20
Posts: 1
Jaime 现在声名狼藉
Default wordpress 通过get_category_by_slug 和 get_category函数获取分类的文章数

get_category_by_slug() 根据分类别名获取分类数据

用法:<?php get_category_by_slug($slug) ?>

参数:$slug 分类别名 类型为字符串

返回的值:数组

示例:

<?php
$cat = get_category_by_slug($slug);
echo $cat->term_id; //取得分类id
echo $cat->count; //取得分类文章数统计
echo $cat->description; //获取分类的描述
echo $cat->name; //获得分类的名称
echo $cat->slug; //获取分类的别名
echo $cat->parent; //获得对当前分类的父级分类的引用
?>

此方法获取的文章数仅仅是你所指定的分类的,不包括它的子分类。

get_category() 根据分类编号或分类对象获取分类数据

用法:<?php get_category( $category,$output,$filter) ?>

参数:

$category 分类ID号或分类行对象,类型为整数或者对象,必需

$output 常量对象,ARRAY_A,或ARRAY_N,默认值为object,类型为字符型,可选

$filter 默认值为raw,否则将不使用WordPress定义的过滤器。类型为字符型,可选

示例:

<?php echo get_category($category_ID)->count; ?>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Steps to Change Your Table Prefix in WordPress Abby WordPress 0 2014-04-14 03:40 PM
Install WordPress on IIS topvip Blog(博客)/Wiki(维客)/RSS/Cms 1 2010-01-25 08:31 PM
让wordpress首页显示特殊页面(flash首页等) yahoo Blog(博客)/Wiki(维客)/RSS/Cms 0 2009-02-25 06:58 AM
wordpress 搜索引擎优化的二十条实用技巧 car 搜索引擎优化 0 2008-03-11 08:33 AM
WordPress 中文包 sunshine Blog(博客)/Wiki(维客)/RSS/Cms 0 2007-03-12 10:16 AM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 10:54 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.