WORDPRESS:如何获取SELECT字段的行数

时间:2017-01-21 08:30:52

标签: wordpress rowcount

以下是我的代码,无论我输入什么代码,我总是得到总计数而不是单个国家/地区计数,请帮助用代码逻辑替换伪代码 我有一个自定义的帖子类型字段=事件 在事件中,我有选择字段,其中包含2个值" INDIA'和"美国" 我想在这两个国家/地区获得单个用户发布的帖子数量。

    <?php 

// args
$args = array(
'numberposts'   => -1,
'post_type'     => 'event',
'meta_query'    => array(
    'relation'      => 'OR',
    array(
        'key'       => 'location',
        'value'     => 'INDIA',
        'compare'   => 'LIKE'
    ),
    array(
        'key'       => 'location',
        'value'     => 'US',
        'compare'   => 'LIKE'
      )
   )
);


// query
 $the_query = new WP_Query( $args );

 ?>
<?php if( $the_query->have_posts() ): ?>

<?
   ******************************************
  //Add code here to count the posts  of INDIA and US 
  Psuedo code is as shown below 
 iF meta.LOCATION ="INDIA"
  get row count (Locaton-->india)
 endif
iF meta.LOCATION ="US"
  get row count (Locaton-->india)
endif
***********************************

<?php endif; ?>
<?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>

0 个答案:

没有答案