0
我想在我的插件中寫一些代碼,它只顯示評論爲具有爲自定義分類標準設置的特定值的帖子。我的設立是:
自定義後類型 - 對象
自定義分類 - 源
示範值 - ABC博物館檢索評論只是爲了匹配自定義分類標準的帖子
評論爲對象 使我可以通過用戶和每個自定義後取回評論
我曾嘗試過:
$meta_query = array('key' => 'sources', 'value' => 'ABC Museum');
$args = array(
'number' => 5,
'post_type' => 'Object',
'meta_query' => array($meta_query)
);
$comments_query = new WP_Comment_Query;
$comments = $comments_query->query($args);
但是這會返回一個空數組。這只是我的一個愚蠢的語法錯誤,或者我誤解了meta_query的用法,它不適用於自定義分類法和自定義帖子類型?
看着http://pippinsplugins.com/querying-comments-with-wp_comment_query-and-meta-query-in-3-5/我認爲它可能是後者 - 元必須與評論相關,而不是它添加到的帖子是否正確?不幸的是http://codex.wordpress.org/Function_Reference/get_comments在細節和例子上相當薄弱!
感謝
你看過** wp_list_comments **? - http://codex.wordpress.org/Function_Reference/wp_list_comments - 也查看代碼中的** WP_Comment_Query ** - http://codex.wordpress.org/Class_Reference/WP_Comment_Query - –