Running a Loop using the same category as a post
-
Ok so here’s my issue.
I have several pages that has multiple tabs on it. Each tab is aimed to grab content from different custom post types. Each post within those post-types are categorized by the page they will appear on.
For example:
Lisa has a page
under she has 5 tabs, one for news, video, photos, etc.each of those tabs is a custom-post -type. The way the are to show up on the page is by selecting the ‘lisa’ category before publishing.
I’ve run into an issue, I can’t figure out how to get each person’s category to up based on the page you are on. Basically, how do get the wordpress loop to change the category id to be the same as the category the page is on?
Here’s the code:
<?php query_posts( 'post_type=results' . '&cat=jessicaeye'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <section> <div class="result"> <header> <h1> <?php the_field('winloss') ?> </h1> </header> <footer> <h1> <?php the_field('type') ?> </h1> <h1>Round</h1> <h1> <?php the_field('round') ?> </h1> </footer> </div> <div class="review"> <header> <div class="back"></div> versus <strong><?php the_field('opponent') ?></strong> on <?php the_field('date') ?> </header> <article> <div class="back"></div> <?php the_field('summary') ?> </article> </div> </section> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <?php endif; ?>
Help would be very much appreciated on this subject.
- The topic ‘Running a Loop using the same category as a post’ is closed to new replies.