まず、これらの種類の複雑なクエリにWordPressクエリオブジェクトを使用する必要があります。それはあなたにもっと多くの議論をするでしょう。
だから、あなたができる:
うまく動作するはずです
// Let's prepare our query:
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'basePrice',
'compare' => 'EXISTS'
),
)
);
$the_query = new WP_Query($args);
// Array to save our matchs:
$pages = array();
// The Loop
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
// Let's take what we need, here the whole object but you can pick only what you need:
$pages[] = $the_query->the_post();
}
// Reset our postdata:
wp_reset_postdata();
}
。
get_pages()
を使用する別の方法は、すべてのページを取得することです - >ループする - > get_post_meta()if文を作成します。値がある場合は、現在のページを配列に追加します。しかし、あなたが想像することができるように、すべてのページを読み込まなければならないのに対し、すべてのページを読み込まなければなりません。
希望すると、