編輯:問題是腳本超時。在PHP頁面列出所有帖子從WordPress站點
直到WordPress版本3.2.1我在我的網站根目錄中的一個名爲'list.php'的頁面上使用了這段代碼。當我轉到此頁面時,我的網站上發佈的所有帖子的固定鏈接都會顯示出來。
一旦我安裝WordPress 3.5.1,此代碼停止工作。我們如何解決它?
<?php
require_once('wp-config.php');
require_once('wp-includes/wp-db.php');
global $post;
$myposts = get_posts('numberposts=-1&offset=1');
foreach($myposts as $post){
echo trim(the_permalink())."<br>";
}
?>
您是否嘗試將'numberposts'改爲'posts_per_page'? –
我做到了不行。 – Zox
但問題是腳本超時,我以爲我沒有解決它。 – Zox