简体   繁体   English

结合两个 PHP/MySQL 查询

[英]Combine Two PHP/MySQL queries

I'd like to combine two php/mysql queries against the wp_posts table using the code below.我想使用下面的代码针对 wp_posts 表组合两个 php/mysql 查询。

However, as you can see, there's an error there with the second post_type.但是,如您所见,第二个 post_type 存在错误。 The second post_type is 'post', and is never recognized.第二个 post_type 是“post”,永远不会被识别。 :-( :-(

How would I make that an "AND", to gather BOTH the 'membercontent' and 'post' data ?我如何使它成为“AND”,以收集“会员内容”和“发布”数据? The same question applies to the 'value' statement just below it.同样的问题适用于它正下方的“价值”声明。 'true' and 'yes'. '真' 和 '是'。

        <?php $args = array( 
            'post_type' => 'membercontent', 'post',
            'meta_query' => array(
                            array(
                             'key'     => 'tt_freemium',
                             'value'   => 'true', 'yes',
                            ),
                           ),
            'orderby' => 'post_date', 
            'order' => 'DESC', 
            'posts_per_page' => '200' );
        `$ourposts = new WP_Query( $args );?>

Just figured it out.刚刚想通了。 Duh.呃。 Had the answer all along....ARRAYS!一直有答案......阵列!

<?php $args = array( 
    'post_type' => array ('membercontent', 'post',),
    'meta_query' => array(
            array(
                'key'     => 'tt_freemium',
                'value'   => array ('true', 'yes',),
                ),
            ),
    'orderby' => 'post_date', 
    'order' => 'DESC', 
    'posts_per_page' => '200' );
    $ourposts = new WP_Query( $args );?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM