簡體   English   中英

在wordpress中以相反的順序顯示帖子?

[英]Show posts in reverse order in wordpress?

我復制了index.php頁面,並將其稱為old.php。 然后我替換了query_posts(); for query_posts( $query_string . '&order=ASC' ); 我希望能夠將index.php用作普通的wp主頁,並使用old.php以相反的順序顯示帖子。 (以為您了解我的想法)如何用漂亮的URL調用old.php,以便訪問者可以相反的順序查看帖子列表?

您是否真的需要將其放在單獨的PHP文件中? 如果index.phpold.php之間的唯一區別是帖子的顯示順序,則您可以僅使用index.php ,並將順序作為參數傳遞:

的index.php

$order = 'DESC';
if (isset($_GET['order']) and $_GET['order'] == 'reversed') {
  $order = 'ASC';
}
$posts = query_posts($query_string . '&order=' . $order);

如果您的URL看起來像/index.php?order=reversed (仍然看起來很漂亮),則會以相反的順序顯示帖子。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM