2016-03-22 15 views
0

belirli sınıflandırmayı dışla, ilk bubir derdim var sorguda

$page_id = get_queried_object_id(); 
$post = get_post($page_id); 
$filter_args = array(
    'tax_query'=>array(), 
    'meta_query'=>array() 
); 

$posts_per_page = 5; 
$args = array(
    'posts_per_page' => $posts_per_page, 
    'post_type' => 'property', 
    'orderby' => 'date' 
); 

$args = array_merge($args, $filter_args); 
$query = new WP_Query($args); 

$items = array(); 

if(count($query->posts) > 0){ 
    $items = $query->posts; 
} 

$acf_fields = get_acf_fields(array('general_property_fields', 'property_price')); 
foreach($items as $k=>$v){ 
    $items[$k]->acf = get_acf_data($v->ID, $acf_fields); 
    $items[$k]->pc = sb_get_price($v->ID); 
} 

get_acf_fields bu konuda bu soru endişelenmeyin, kişisel fonksiyondur benim kodudur.

Ve bu istediğim değerleri elde benim döngü.

<?php foreach ($items as $v) { 
    $status = $v->acf['c_status']; 
    $status_name = get_term_by('id', $status, 'type'); 
?> 
<?php if ($status_name) { ?> 
     <div class="sb-sidebar-featured-type"> 
     <?php 
     $title_status = $status_name->name; 
     $status = explode(' ', $title_status); 
     ?> 
     <div class="sidebar-featured-transaction"><?=($status_name) ? $status[0] : '';?></div> 
     </div> 
<?php } ?> 

Tüm çalışmalar ince, ancak statü, "indirim", "teklif" i "ile sonuçlarını exlude istiyorum "satıldı" adı durumuyla taksonomisinde, örneğin i elde edersek gelen bana tüm değerleri vermek , taksonomisinde "satıldı ama emin olun bilmiyorum teşekkürler: D İşte

cevap

2
Will you please try like this: 
<?php if ($status_name != 'sold') { ?> 
     <div class="sb-sidebar-featured-type"> 
     <?php 
     $title_status = $status_name->name; 
     $status = explode(' ', $title_status); 
     ?> 
     <div class="sidebar-featured-transaction"><?=($status_name) ? $status[0] : '';?></div> 
     </div> 
<?php } ?> 
+0

için çalıştığını, ancak cevap beni bunu çözmek için kılavuz, teşekkürler –

0

kod tam somelse

<?php foreach ($items as $v) { 
    $tax_type = $v->acf['c_type']; 
    $status = $v->acf['c_status']; 
    $type_name = get_term_by('id', $tax_type, 'type'); 
    $status_name = get_term_by('id', $status, 'type'); 
    if ($status_name) { 
     $check_status = trim($status_name->slug); 
    } 
    if ($check_status != 'sold' && $check_status != 'vendido') { 
?> 
     <div class="sidebar-featured-cont"> 
      <div class="sidebar-featured"> 
       <a class="sidebar-featured-image" href="<?=get_permalink($v->ID)?>"> 
        <img src="<?=$v->acf['c_gallery'][0]['sizes']['property-listing']?>" alt="" /> 
        <?php if ($status_name) { ?> 
         <div class="sb-sidebar-featured-type"> 
          <?php 
           $title_status = $status_name->name; 
           $status = explode(' ', $title_status); 
          ?> 
          <div class="sidebar-featured-transaction"><?=($status_name) ? $status[0] : '';?></div> 
         </div> 
        <?php } ?> 
       </a> 
       <div class="sidebar-featured-title"><a href="estate-details-right-sidebar.html"><?=$v->post_title?></a></div> 
       <div class="sidebar-featured-price">$ <?=$v->pc?></div> 
       <div class="clearfix"></div>       
      </div> 
     </div> 
    <?php } ?> 
<?php } ?> 
İlgili konular