网络营销电子商务研究中心  
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:31 AM
Jadiel Jadiel is offline
初级会员
 
Join Date: 2013-07-08
Posts: 1
Jadiel 现在声名狼藉
Default wordpress 获取分类ID,分类标题,分类描述,分类链接url函数

get_cat_ID() 根据分类名称获取分类ID

用法:<?php get_cat_ID( $cat_name ) ?>

参数:$cat_name 分类名称默认值为"General"。类型为字符型,可选

返回的值:出错时返回0,成功则返回分类ID号,类型为整数

示例:

<?php
$category_id = get_cat_id('Category Name');
query_posts('cat='.$category_id);
if (have_posts()) : while (have_posts()) : the_post();
the_content();
endwhile; endif;
?>

get_category_link() 根据分类ID获取分类的链接URL

用法:<?php get_category_link( $category_id ) ?>

参数:$categroy_id 分类ID号 默认值:None,类型为整数,必需

返回的值:分类URL 字符串型

示例:

<?php
$category_id = get_cat_ID( 'Category Name' );
$category_link = get_category_link( $category_id );
?>
<a href="<?php echo $category_link; ?>" title="Category Name">Category Name</a>

the_category() 显示文章所属分类目录的链接。此标签必须在主循环中。

用法:<?php the_category( $separator, $parents ); ?>

参数:$separator 显示在分类目录链接之间的文字或字符。默认以无序列表方式排列分类目录链接。字符串型

$parents 怎样显示子分类目录链接,字符串型,值包括:

'multiple'——显示父分类与其子分类的链接以展示"父子"关系

'single'——只显示子分类的链接,用链接文本标出"父子"关系

默认值为显示子分类链接,无标识文字。

示例:

用逗号隔开分类目录

列出分类目录,(在分类目录数量多于一个的情况下)以逗号作为分隔符。

<p>This post is in: <?php the_category(', '); ?></p>


用箭头隔开分类目录

列出分类目录,以箭头(>)作为分隔符。(使用时请注意,有些访问者可能会将分类>分类这种格式解读为一对具有“父子”关系的分类。)

<p>Categories: <?php the_category(' &gt; '); ?></p>


single_cat_title() 显示或返回当前页面的分类目录标题。

对那些显示WordPress标签而非分类目录标题的页面(如"/tag/carceer"),该标签显示或返回标签名称。该标签只能用在WordPress主循环(loop)之外。

用法:<?php single_cat_title( $prefix, $display ); ?>

默认用法: <?php single_cat_title('prefix'=>,'display'=> true ); ?>

参数:

$prefix 输出时在标题前的文本信息。默认值:None,类型是字符串,可选

$display 显示标题(TRUE)或返回标题以便用在PHP中(FALSE)。默认值:TRUE,类型是布尔型 可选

示例:

下面这个例子在分类目录标题后显示“当前分类:”字样:

<p><?php single_cat_title('当前分类是'); ?></p>

输出:当前分类是wordpress

下面这个例子将当前分类目录标题赋值给变量$current_category以用在PHP中。

<?php $current_category = single_cat_title("", false); ?>

category_description() 返回用户在当前分类目录所填写的说明信息

用法:<?php echo category_description( $category ); ?>

参数:$category 被返回说明信息的分类目录的数值型ID。若用户未指定分类目录,默认为当前分类目录。类型为整型

示例:

<div><?php echo category_description(3); ?></div>

返回结果:WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.

<div><strong><?php single_cat_title('当前分类'); ?>
</strong>: <?php echo category_description(); ?></div>

返回结果:当前分类WordPress: WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.
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.