Home Forums General Issues problems using ACF field to display specific posts


problems using ACF field to display specific posts

  • Hello

    I have a custom wordpress post type called featured, and used ACF to add a field called featured_type, I am working on some shortcode to only show specified records

    $posts = get_posts(array(
    “post_type” => “featured”,
    “featured_type” => “about”,
    “orderby” => “date”,
    “order” => “DESC”,
    “posts_per_page” => 6

    but instead of showing only the posts which are marked about it is showing all, the featured_type field was set up as a checkbox, I am pretty sure I am missing something pretty simple, can anyone point me in the right diection?


  • Envirodefence,

    It looks like you need to do a meta_query in your get_posts() function. You can find the docs here: Look under the Custom Fields advanced section for an example on how to query a checkbox. Essentially, you will add a query field like so:

    'meta_query'	=> array(
    			'key'	  	=> 'featured_type',
    			'value'	  	=> 'about',
    			'compare' 	=> '=',
  • thanks, this example and the link should help sort it out

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘problems using ACF field to display specific posts’ is closed to new replies.