0
我有很多種類,但對於clearity我會做的只有兩個例子: 顯示網頁和帖子在歸檔
- 新聞包含許多帖子頁面(我已在
functions.php
中添加此功能)
我要那archive.php
顯示:
- 當用戶選擇類別新聞
- 的頁面,當用戶選擇的類別產品
目前WordPress的deafult的職位只顯示帖子和而不是頁面。
我知道這可以通過在functions.php
中添加一個簡單的函數來實現,但我無法找到它。
編輯:對於自定義後鍵入「書籍」的另一個項目我用這個代碼
function query_post_type($query) {
$post_types = get_post_types();
if (is_category() || is_tag()) {
$post_type = get_query_var('books');
if ($post_type) {
$post_type = $post_type;
} else {
$post_type = $post_types;
}
$query->set('post_type', $post_type);
return $query;
}
}
add_filter('pre_get_posts', 'query_post_type');
是否有類似的東西,我的情況?
我有一個適用於所有類別的單個archive.php。另外,我無法指定要查詢的類別。請參閱第一篇文章中的修改。 – 2013-03-19 12:37:40