WordPress.org

Forums

Posts 2 Posts
[resolved] Posts 2 Posts within a loop (8 posts)

  1. jduffell
    Member
    Posted 1 year ago #

    Hi there, I'm running a loop to display classes, using the post type 'class' is it possible within this query to then add run the posts 2 posts connected type 'Class - Teacher' within this? when I add the following code, it doesn't output despite there being connections.

    <?php query_posts('post_type=class&showposts=-1&orderby=title&order=asc'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <?php the_title(); ?>
    
    <?php
    $connected = new WP_Query( array(
    'connected_type' => 'Class - Teacher',
    'connected_items' => get_queried_object(),
    ) );
    if ( $connected->have_posts() ) : ?>
    ?>
    <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    <?php the_title(); ?>
    <?php endwhile; ?>
    <?php
    wp_reset_postdata();
    endif;
    ?>
    
    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>

    The basic idea is to list night classes, along with the teachers who will run the class, just not sure where to go from here. Help much appreciated, thanks

    http://wordpress.org/plugins/posts-to-posts/

  2. WhiteEagle1985
    Member
    Posted 1 year ago #

    I'm interested in this as well, because this could let me show chapters of a story at my fan fiction archive without needing to wait for a fan fiction plugin!

  3. jduffell
    Member
    Posted 1 year ago #

    @WhiteEagle1985 I've been having a tinker but I'm struggling to achieve the desired result. Have you had much luck ?

    ^JD

  4. WhiteEagle1985
    Member
    Posted 1 year ago #

    I've found another way which is less complicated than using this plugin.

  5. jduffell
    Member
    Posted 1 year ago #

    @WhiteEagle1985 any tips?

  6. WhiteEagle1985
    Member
    Posted 1 year ago #

    CustomPress (from WPMU DEV) and Organize Series can work well, even if they cost money to fully implement. ;)

  7. jduffell
    Member
    Posted 1 year ago #

    cheers, will have a gander, really liked this plugin just couldn't get my head around this :(

  8. jduffell
    Member
    Posted 1 year ago #

    I feel like an idiot, within the code, I'd used $postt, my damn fat fingers.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.