tjobbe
Member
Posted 9 months ago #
Is it possible to somehow use the more fields plugin to pull data into my query_posts code?
I want to set a category number in my page, and then have more fields echo it to my query_posts code.
So <?php query_posts('cat=37&posts_per_page=1'); ?>
becomes something like this:
<?php query_posts('cat=meta("reviewQuote")&posts_per_page=1'); ?>
How would I do this?
James Olney
Member
Posted 8 months ago #
I had the same problem and in the process was advised not to use query_posts as they can muck things up globally so use this instead (replace catid with whatever you have named your custom field and it will suck the ID number in:
<?php $my_query = new WP_Query(array( 'cat' => get_post_meta($post->ID, 'catid', true), 'posts_per_page' => 5, )); if ($my_query->have_posts()): ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?> titles, content etc goes here
<?php endwhile; ?> <?php endif; ?><?php wp_reset_query(); ?>