Support » Plugins » Custom Field in wp_query

  • Hi there.

    I have a page template that I am also using to display some posts. So – for example, a portfolio page, where I want to display the_content and then below that I would like to display some posts from a category.

    No problems there. I can do that through a page template. Here’s the part I can’t work out:

    I would like the person who creates the page to choose which category the posts come from. So. I was wandering – is there a way of setting up a custom field in a page (say “featured_category”) and then use that custom field in the wp_query that displays the posts?

    So something along the lines of

    <?php $recent = new WP_Query("category_name=$key&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>

    But I’d need to pull the $key from the custom field of the page that is using the template.

    Thanks for your time.
    Andy

  • The topic ‘Custom Field in wp_query’ is closed to new replies.