2014-07-17 2 views
0

대행사를위한 여행 웹 사이트를 개발 중입니다. 사용자가 "출발 선택"과 같은 옵션을 선택할 수있게하고 선택한 옵션에 사용할 수있는 모든 출발지와 함께 루프를 필터링 할 수있게하려고합니다. 예 : 시카고 출발을 모두 확인하려면 루프가 시카고 출발 만 표시합니다!Wordpress 필터 루프의 WP_query 값

<?php 
    $args = array(
    'post_type'  => 'travel_packs', 
    'order'   => 'ASC', 
); 
    $the_query = new WP_Query($args); 

    if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); 
?> 

//The loop: 
<a href="<?php the_permalink(); ?>"> 
    Destination: <?php the_field('destination'); ?> 
    Departing from:<?php the_field('departures'); ?> 
    Price:<?php the_field('price'); ?> 
</a> 

<?php endwhile; endif; ?> 

은 내가 $_GET 방법에 대해 생각,하지만 난 the_field('departures');으로 동화하는 방법을 잘 모르겠지만, 내가 트랙에서 나는 것 같아요!

감사합니다.

답변

0

당신은 당신이 출발에 대한 값을 받아 변수를 가질 수 시카고 대신에이

$args = array(
'post_type'  => 'travel_packs', 
'order'   => 'ASC', 
'meta_key' => 'departures', 
'meta_value'  => 'Chicago' 
); 

을 시도해야합니다.

관련 문제