WordPress.org

Ready to get started?Download WordPress

Forums

Feed Custom Post Type into Secondary Loop (1 post)

  1. potato_cakes
    Member
    Posted 1 year ago #

    I need multiple loops on a page and have created them as such

    global $post;
    $args = array( 'numberposts' => 3, 'category' => 10 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?> "><?php the_title();?></a></li>
    <?php endforeach; ?>

    I have a custom post type (foo_post_type) which should be used as a conditional while the loop runs. For example, for each post in this loop:

    if ('foo_post_type' == 'xyz' || 'foo_post_type' == '0' && 'category' => 10) {
     ...then display in the loop.....
    }

    But I am able to grab the custom post type for each post in the loop before the loop runs. And if I grab the custom post type during the loop it returns the same (usually incorrect) value. Where can I stick this foo_post_type in the loop shown at the top so it displays and evaluates each post bringing back the latest 3 which adhere to each condition?

    (Unfortunately, I do not have a public link to the site.)

Topic Closed

This topic has been closed to new replies.

About this Topic