WP Advanced custom field value in query posts array

I need to put an advanced custom field value (category number) from page to query_posts array. Is it somehow possible?

On a single page I’m trying to show posts from category, which number is value of this custom field.

Read More

Ideal and of course non-functional case:

query_posts(array('category__and'=>array( the_field("category"); ,99), 'posts_per_page'=>6));

Related posts

1 comment

  1. the_field() displays a meta value. You’ll want to use get_field() (which returns a meta value) instead:

    query_posts(array('category__and'=>array( get_field("category"); ,99), 'posts_per_page'=>6));
    

    In somewhat unrelated news, you should really consider avoiding the use of query_posts.

Comments are closed.