我正在使用wordpress主題,我想根據類別在不同的頁面上顯示帖子。如何在wordpress的不同頁面上顯示不同類別的不同帖子?
例如頁面名稱是「博客」,帖子類別是postBlog,你能告訴我如何根據類別使用帖子。
感謝
我正在使用wordpress主題,我想根據類別在不同的頁面上顯示帖子。如何在wordpress的不同頁面上顯示不同類別的不同帖子?
例如頁面名稱是「博客」,帖子類別是postBlog,你能告訴我如何根據類別使用帖子。
感謝
你到底做可以WordPress Category Template實現。
從食品:
For instance, when a viewer clicks on a link to one of the Categories on your site, he or she is taken to a page listing the Posts from that particular Category in chronological order, from newest Posts at the top to oldest at the bottom.
您可以創建你的主題文件,名爲:category.php
,把loop
它的內部,然後WordPress會自動爲你做的。
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
然後用頁面填寫您的需求。您可以檢查文檔The Loop
here in this link。
建立在你的主題目錄模板category-catname.php
或category-catID.php
。
我覺得人們會感到困惑,試圖使用頁面時,他們實際上更好使用類別。如果您想讓博客文章顯示在不同的網址或「網頁」上,那麼您所要做的就是設置您的類別並將這些類別放入您的菜單中。然後,當您發佈時,請確保選擇要顯示該帖子的類別。你根本不需要使用網頁。頁面對靜態內容更好。
祝你好運,我希望這會有所幫助。
請檢查我的答案。 –