我填充了以下变量:
$posts = wp_get_recent_posts(array (
\'numberposts\' => 4,
\'post_status\' => \'publish\'
));
$categoryPosts = wp_get_recent_posts(array (
\'numberposts\' => 4,
\'category\' => get_cat_ID(\'events\'),
\'post_status\' => \'publish\'
));
现在帖子应该有1篇帖子,默认示例hello world帖子。第二个应该是空的an数组,因为该类别有0个与其关联的帖子。
相反,我回来了(两次):
array(24) { ["ID"]=> int(1) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2015-01-28 20:49:24" ["post_date_gmt"]=> string(19) "2015-01-28 20:49:24" ["post_content"]=> string(130) "Welcome to demosite network. This is your first post. Edit or delete it, then start blogging!" ["post_title"]=> string(12) "Hello world!" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(4) "open" ["ping_status"]=> string(4) "open" ["post_password"]=> string(0) "" ["post_name"]=> string(11) "hello-world" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2015-01-28 20:49:24" ["post_modified_gmt"]=> string(19) "2015-01-28 20:49:24" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(49) "http://waters-edge-winetailor.demosite.rocks/?p=1" ["menu_order"]=> int(0) ["post_type"]=> string(4) "post" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "1" ["filter"]=> string(3) "raw" }
我得到它两次,因为我有两个循环在两个数组上循环,var转储数组。
我的问题是:$categoryPosts
数组为什么我要取回上面的数组?我应该什么都不知道对不对