所以我创建了一个瞬态对象get_posts()
以获取基于某个参数的一系列帖子。瞬态是存储的-它是创建的-耶-现在我试着写这个循环:
public function transient_loop($transient_name){
global $post;
if(false !== get_transient($transient_name)){
foreach(get_transient($transient_name) as $post){
setup_postdata($post);
$this->_loop_content();
}
}
}
这会查找临时名称,如果它存在,在其上循环-设置post数据,然后从那里调用一个方法,该方法会遍历并执行典型的循环内容,如图像、标题、链接等-所有这些都是典型的jazz,
现在回来的是:Notice: Trying to get property of non-object in /var/www/wordpress/wp-includes/query.php on line 3645
堆栈跟踪显示最后调用的是setup_postdata($post)
所以我把var甩了$post
得到了int 1
不确定这是否正常。所以我决定var\\u转储瞬态-可能一个帖子或一组帖子根本没有通过。
Note: 我使用的是xdebug,这就是为什么对象的格式都很好。但我做到了:var_dump($transient_name)
然后回来了:
object(WP_Post)[259]
public \'ID\' => int 1
public \'post_author\' => string \'1\' (length=1)
public \'post_date\' => string \'2013-08-16 22:57:23\' (length=19)
public \'post_date_gmt\' => string \'2013-08-16 22:57:23\' (length=19)
public \'post_content\' => string \'Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!\' (length=86)
public \'post_title\' => string \'Hello world!\' (length=12)
public \'post_excerpt\' => string \'\' (length=0)
public \'post_status\' => string \'publish\' (length=7)
public \'comment_status\' => string \'open\' (length=4)
public \'ping_status\' => string \'open\' (length=4)
public \'post_password\' => string \'\' (length=0)
public \'post_name\' => string \'hello-world\' (length=11)
public \'to_ping\' => string \'\' (length=0)
public \'pinged\' => string \'\' (length=0)
public \'post_modified\' => string \'2013-08-16 22:57:23\' (length=19)
public \'post_modified_gmt\' => string \'2013-08-16 22:57:23\' (length=19)
public \'post_content_filtered\' => string \'\' (length=0)
public \'post_parent\' => int 0
public \'guid\' => string \'http://localhost/wordpress/?p=1\' (length=31)
public \'menu_order\' => int 0
public \'post_type\' => string \'post\' (length=4)
public \'post_mime_type\' => string \'\' (length=0)
public \'comment_count\' => string \'1\' (length=1)
public \'filter\' => string \'raw\' (length=3)
public \'format_content\' => null
那么错误是什么呢?