下面的代碼返回即使我知道有一些具有給定的post_parent
ID職位空數組:get_posts通過post_parent返回空數組
$args = array(
'post_parent' => 211167,
);
$posts_array = get_posts($args);
$data->subfolder_count = sizeof($posts_array);
我已經使用CLI嘗試,並得到相同的結果
(12:05:29) mu-plugins/$ wp post get 211169
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| ID | 211169 |
| post_author | 12449 |
| post_date | 2016-08-14 11:21:26 |
| post_date_gmt | 2016-08-14 16:21:26 |
| post_content | |
| post_title | SubFolder Two |
| post_excerpt | |
| post_status | publish |
| comment_status | closed |
| ping_status | closed |
| post_password | |
| post_name | subfolder-two |
| to_ping | |
| pinged | |
| post_modified | 2016-08-14 11:21:26 |
| post_modified_gmt | 2016-08-14 16:21:26 |
| post_content_filtered | |
| post_parent | 211167 |
| guid | [redacted] |
| menu_order | 0 |
| post_type | [redacted] |
| post_mime_type | |
| comment_count | 0 |
+-----------------------+--------------------------------------+
(12:05:40) mu-plugins/$ wp post list --post_parent=211167
+----+------------+-----------+-----------+-------------+
| ID | post_title | post_name | post_date | post_status |
+----+------------+-----------+-----------+-------------+
+----+------------+-----------+-----------+-------------+
如果你能告訴我我做錯了什麼,我會很感激。
謝謝傑拉德。你是絕對正確的。我得出了同樣的結論。 –