WP_Query & Conditional Statements OR how to pull in a post based on the page id
-
-I am trying to use 1 template (inner.php) for multiple Pages.
-I would like each page to pull in information from multiple posts.
-One thing I am including is ‘header image’ which is an image and caption.
-I am using wP_Query to grab & displays posts with certain categories or tagsI am wondering if I can use Conditional Statements within a query?
Or, is there something I can add to the code below to have the results be based on the post tag matching up with the Page ID or Title?
<div id="headerImage"> <?php $headerImage = new WP_Query(); $headerImage->query('category_name=headerImage&showposts=1'); while($headerImage->have_posts()) : $headerImage->the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>" style="background:white;"> <div class="entry"> <?php the_content(''); ?> </div> <?php endwhile; ?> </div>
Something like this…
$headerImage->query('category_name=headerImage&tag=('the_ID()')showposts=1');
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘WP_Query & Conditional Statements OR how to pull in a post based on the page id’ is closed to new replies.