Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use Advanced Custom Fields in a post type and I would like to display them in another page. In addition, I would filter them according to 3 categories (3 tabs), for this I used a select field. Here is the query that I made in my template page but I am not able to code the following to display the content of various fields of my post type.

$projets_actuels = get_posts(array(
'post_type' => 'projets',
'meta_key' => 'etat',
'meta_value' => 'actuel'
share|improve this question
Following the get_posts() function are you looping through the results of that query? foreach ( $projets_actuels as $post )? –  developdaly Apr 18 '12 at 21:41
Yes I tried this but there is probably something I did not do well because it did not work. –  carob Apr 19 '12 at 16:10
add comment

1 Answer

I solved my own problem. Here is the code:

$args = array( 'post_type' => 'projets', 'meta_key' => 'etat', 'meta_value' => 'actuel' ); 
$loop = new WP_Query( $args ); 
while ( $loop->have_posts() ) : $loop->the_post(); 

There maybe other solutions but it works.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.