• Hi there. For long and complicated reasons I am needing to use query_posts within the wordpress loop. Is this possible? if so how?

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    -the content etc-
    
    <?php query_posts('showposts=99&cat=1153'); ?>
    <?php while (have_posts()) : the_post(); ?>	
    
    <li><?php the_title(); ?></li>
    
    <?php endwhile; ?>
    
    <?php endwhile; else: ?>
    <?php endif; ?>

    I understand the code I place here might be ridiculous…

    The reason is: I’m making a discography. I want a single post to have a list of posts within a certain category. The category name will be placed there using custom fields.

Viewing 1 replies (of 1 total)
  • Thread Starter zefdesign

    (@zefdesign)

    Okay I did some more searching and have found the perfect code:

    <?php $my_query = new WP_Query('category_name=<strong>HERE-IS-WHERE-I-WANT-TO-INSERT-CUSTOM-FIELD</strong>&orderby=title&order=asc&showposts=100');while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate=$post->ID;?>
    
    <li><?php the_title();?></li>
     <?php endwhile; ?>

    How could I insert a custom field within that php code???
    I tried this:

    <?php
    $post_title = get_post_meta($post->ID, 'post_title', $single = true);
    ?>

    then inserting $post_title.

    Didn’t work.

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts within the loop?’ is closed to new replies.