2017-06-16 30 views
0

我想從我的wordpress使用Ajax和獲取信息得到類職位:WordPress的如何從先進的自定義字段

首先,這是我能得到的是從這一類from'mark」類別和領域‘標誌’ 。 (它的工作原理)

二是讓其他ACF而不是從類,但是從帖子裏面有「報價」自定義後類型,我不知道如何得到它

我的代碼:

$mark = $_GET['mark']; 
$categories = $_GET['category']; 
$output = ''; 


$myquery['tax_query'] = array(
    'relation' => 'AND', 
    array(
     'taxonomy' => 'offer_category', 
     'terms' => array($category, 
     'field' => 'slug', 
    ), 
    array(
     'taxonomy' => 'mark_offer', 
     'terms' => array($mark), 
     'field' => 'slug', 
    ), 
); 
$post = query_posts($myquery); 


    $query = new WP_Query($myquery); 
    $ind=0; 
    $last = $query->post_count; 
       if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); 

       $ind++; 


       $post_fields = get_fields(); 
        // echo get_the_title(); 


       $myMark = wp_get_post_terms(get_the_ID(), 'mark_offer'); 

       $markId = $myMark[0]->term_id; 

       $markLogo = get_field('logo', 'term_'.$markId); 

回答

0

當您使用自定義後的類型,你需要做這樣的事情:

 query_posts([ 
     'post_type' => 'YOURTYPE', 'meta_key' => 'YOUR_CUSTOM_FIELD', 'meta_value' => 'YOUR_CUSTOM_VALUE' 
    ]);