PHP函数,post_type需要很少的输入(wordpress主题函数)

时间:2014-05-03 12:01:53

标签: php wordpress function

wordpress主题功能中的功能

function child_post_list($title){
$args = array('posts_per_page'=>1, 'post_type' => 'updatelist');
$update_list_post = get_posts( $args ); //UPDATE LIST post
if(isset($update_list_post[0])){
    $args = array('meta_key'=>'_wpcf_belongs_updatelist_id', 'meta_value' => $update_list_post[0]->ID,'post_type' => "'indon-stat';'myanmar-stat'");
    $child_posts = get_posts( $args ); //the child listing of UPDATE LIST post
    foreach($child_posts as $post){
        if(get_post_meta($post->ID, 'wpcf-biodata-code', true) == $title){ //if the post title is exist within the custom field of the child listing of UPDATE LIST post.
            return 1;
        }
    }
}

}

如您所见,代码的最后一部分

"'indon-stat';'myanmar-stat'");

这绝对是错误的语法,所以我想问一下哪个是正确的?甚至可以为此插入多个post-type?

1 个答案:

答案 0 :(得分:0)

如果要插入多个帖子类型,请尝试将其作为逗号分隔值或JSON字符串插入

'post_type' => "indon-stat,myanmar-stat"