WordPress.org

Ready to get started?Download WordPress

Forums

Query to retrieve post id's under a specific category (1 post)

  1. bigmoose
    Member
    Posted 5 years ago #

    Hi

    My programming skills are a little poor and i'm not having much luck with google or the wordpress documentation on this. What i'm trying to do is inside a loop, retrieve all of the post's ids for posts inside that category, and get information from each of those posts custom fields, then display them in a featured content box.

    Here is the code I have at the moment, i dont seem to be able to parse $post->ID, the code works if I input a post ID, but I cant seem to get this code to output a list of the ID's and then display the 3 posts

    <?php
    $my_query = new WP_Query('category_name=featured&showposts=3');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;
    ?>
    <li class="sliderImage">
      <img class="featimg" src="<?php echo get_post_meta($post->ID, 'thesis_image', $single = true); ?>" alt="<?php the_title(); ?>"  />
      <span><?php the_excerpt(); ?></span>
    </li>
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic