Home › Forums › General Issues › Insert Cat ID into Query › Reply To: Insert Cat ID into Query
I think we’re closer, but no cigar 🙁 but I’ve also moved on to wp-query. I have it set up, but it’s still not pulling the category for the query. Here is my complete loop:
<?php if( have_rows('parts_table') ): ?>
<?php while( have_rows('parts_table') ): the_row(); ?>
<?php
$catquery = new WP_Query( 'order=ASC&orderby=meta_value&meta_key=weight_(lbs.)&showposts=200&cat='.get_sub_field('part_category').'&post_type=sweeps' ); ?>
<table>
<tr><td>Part Number</td><td>Description</td><td>Weight (lbs.)</td>
<?php while($catquery->have_posts()) : $catquery->the_post();
?>
<tr>
<td>
<?php the_field('part_number'); ?>
</td>
<td>
<?php the_field('description'); ?>
</td>
<td>
<?php the_field('weight_(lbs.)'); ?>
</td>
</tr>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</table>
<?php endwhile;?>
<?php endif; ?>
So there is my loop. If I manually enter a cat id it works, but it won’t pull my ACF field. Thanks so far!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.