Php 自定义帖子类型上所有帖子的WP循环特定元框值
我已经为自定义帖子类型上所有帖子的特定于循环的metabox值创建了函数。它工作得很好。代码如下:Php 自定义帖子类型上所有帖子的WP循环特定元框值,php,wordpress,Php,Wordpress,我已经为自定义帖子类型上所有帖子的特定于循环的metabox值创建了函数。它工作得很好。代码如下: $loop = new WP_Query(array('post_type' => 'myposttype', 'posts_per_page' => -1)); while ( $loop->have_posts() ) : $loop->the_post(); $custom_fields = get_post_custom($post->ID); $
$loop = new WP_Query(array('post_type' => 'myposttype', 'posts_per_page' => -1));
while ( $loop->have_posts() ) : $loop->the_post();
$custom_fields = get_post_custom($post->ID);
$my_custom_field = $custom_fields['custommetabox_mb'];
foreach ( $my_custom_field as $key => $value ) {
echo $value . "<br />";
}
endwhile;
我想要的是,如果custommetabox_mbb的值与文本yiedpozi相同,只需循环custommetabox_mb
我如何才能做到这一点?使用
工作正常D谢谢。为什么要打下线?-编辑:我不是指作者的名字。。。我指的是投票。
First = custommetabox_mb
Second = custommetabox_mbb
$args = array('post_type' => 'myposttype', 'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'custommetabox_mb',
'value' => 'yiedpozi',
'compare' => '='
),
array(
'key' => 'custommetabox_mbb',
'value' => 'yiedpozi',
'compare' => '='
)
), 'posts_per_page' => -1,);
$loop = new WP_Query($args);
while ( $loop->have_posts() ) : $loop->the_post();
$custom_fields = get_post_custom($post->ID);
$my_custom_field = $custom_fields['custommetabox_mb'];
foreach ( $my_custom_field as $key => $value ) {
echo $value . "<br />";
}
endwhile;