Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自定义帖子类型上所有帖子的WP循环特定元框值_Php_Wordpress - Fatal编程技术网

Php 自定义帖子类型上所有帖子的WP循环特定元框值

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); $

我已经为自定义帖子类型上所有帖子的特定于循环的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);
  $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;