WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] Combined loops (5 posts)

  1. markus
    Member
    Posted 2 years ago #

    Hi Scribu,

    first of all, thank you very much for putting all this time and effort into this plugin!! It really enhances WordPress usefulness!! Thanks.

    However, I have a problem:

    I am working with a custom post type and custom fields that are connected using your plugin, so within a single post that I get off a custom post type I need to display several connections within the custom post type loop. It does not seem to work, the loops seem to overlap. I apologize if this is a nb question but I am not a full blown developer, rather a UX Designer and heavy CMS consultant :) I have posted my code below. If someone on here could give me some advice, that would be great!

    Thank you,

    Markus

    [55 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

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

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    As the moderator said, please use http://wordpress.pastebin.com/ for sharing the code.

  3. markus
    Member
    Posted 2 years ago #

    Sorry for being so difficult :)

    here is the link to pastie:

    http://www.pastie.org/3543816

  4. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    You might want to have a look at each_connected():

    https://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop

    Also, make sure that get_queried_object_id() returns what you expect:

    http://wordpress.org/support/topic/plugin-posts-2-posts-cant-display-connected-posts-am-i-doing-this-correct

  5. markus
    Member
    Posted 2 years ago #

    Thanks! I am using this code and it works well:

    <?php
    		// Find connected pages
    		$relVenue = p2p_type( 'ven2sess' )->get_connected( $post->ID );
    
    		// Display connected pages
    		echo '<p>Venue:</p>';
    		p2p_list_posts( $relVenue );
    
    		// Find connected pages
    		$relSpeak = p2p_type( 'speak2sess' )->get_connected( $post->ID );
    
    		// Display connected pages
    		echo '<p>Speakers:</p>';
    		p2p_list_posts( $relSpeak );
    	?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic