WIKI使用導(dǎo)航
站長(zhǎng)百科導(dǎo)航
站長(zhǎng)專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢
- 虛擬主機(jī)
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計(jì)算
- 微博營(yíng)銷
- 虛擬主機(jī)管理系統(tǒng)
- 開放平臺(tái)
- WIKI程序與應(yīng)用
- 美國(guó)十大主機(jī)
WordPress:Template Tags/get archives
來自站長(zhǎng)百科
描述[ ]
向按日的存檔顯示一列鏈接??梢栽谝粋€(gè)模板內(nèi)的任何位置使用這個(gè)標(biāo)簽。這個(gè)標(biāo)簽與wp_get_archives()標(biāo)簽類似。
取代[ ]
用法[ ]
%%% <?php get_archives('type', 'limit', 'format', 'before', 'after', show_post_count); ?> %%%
例子[ ]
默認(rèn)用法[ ]
使用默認(rèn)設(shè)置,顯示歸檔鏈接。
<?php get_archives(); ?>
按月歸檔,顯示文章數(shù)目[ ]
在一個(gè)無序列表上顯示所有的歸檔,按月顯示文章的數(shù)目。
<ul>
<?php get_archives('monthly', '', 'html', '', '', TRUE); ?> </ul>
在一個(gè)列表上顯示最近十篇文章[ ]
將十篇最近的文章按行分開,顯示在一個(gè)沒有bullet符號(hào)的列表上。
<?php get_archives('postbypost', '10', 'custom', '', '<br />'); ?>
使用下拉列表[ ]
在一個(gè)下拉列表上顯示按月的歸檔;需要使用javascript,以在網(wǎng)頁上擁有一個(gè)打開的歸檔選擇。 <form id="archiveform" action="">
<select name="archive_chrono" onchange="window.location = (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);"> <option value=''>Select Month</option> <?php get_archives('monthly','','option'); ?> </select> </form>
你也可以使用下面的這個(gè)代碼,比上面的例子中的代碼,運(yùn)行地更好。這個(gè)代碼顯示了按月歸檔的列表,同時(shí)顯示了每月的歸檔文章的數(shù)目。
<select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;"> <option value="">Select month</option> <?php get_archives('monthly',,'option',,,'TRUE'); ?> </select>
有限個(gè)最近文章的列表[ ]
在一個(gè)無序列表上顯示自定義數(shù)目最近文章的列表。
<ul><?php
<ul><?php get_archives('postbypost','10','custom','<li>','</li>'); ?></ul>
參數(shù)[ ]
- type
- (string) 需要顯示的歸檔列表的類型。默認(rèn)為WordPress設(shè)置(在1.5版本中默認(rèn)為'monthly')。有效的參數(shù)值:
- 'monthly' (Default)
- 'daily'
- 'weekly'
- 'postbypost'
- limit
- (integer) 得到的存檔文章的數(shù)目。使用'',沒有限制。
- format
- (string) 存檔列表的格式。有效的參數(shù)值:
- 'html' - 在HTML列表(<li>)標(biāo)簽中。這是默認(rèn)設(shè)置的。
- 'option' - 在精選的或者下拉列表選項(xiàng)(<option>)標(biāo)簽。
- 'link' - 在鏈接(<鏈接>)標(biāo)簽內(nèi)部。
- 'custom' - 自定義列表。
- before
- (string)為格式選項(xiàng)使用'custom' 或者'html'時(shí),在鏈接前顯示的文本。默認(rèn)為''。
- after
- (string) 為格式選項(xiàng)使用'custom' 或者'html'時(shí),在鏈接后顯示的文本。默認(rèn)為''。
- show_post_count
- (boolean)顯示一個(gè)存檔中的文章數(shù)目(TRUE)或者不顯示(FALSE)。當(dāng)類型設(shè)置為'monthly'的時(shí)候,可以使用。默認(rèn)為FALSE。
相關(guān)的[ ]
要使用查詢字符串,傳遞參數(shù),產(chǎn)生一個(gè)歸檔列表,請(qǐng)看看wp_get_archives()