WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
Posts 2 Posts retrieving all records in connected table when no match (6 posts)

  1. jtwg
    Member
    Posted 3 years ago #

    I have three custom post types I'm working with that use Posts 2 Posts: Songs, Albums, and Projects - where a given Song can be connected to an Album and/or a Project.

    I am registering the connections like so:
    p2p_register_connection_type('song', 'album', 'Songs To Albums', true);
    p2p_register_connection_type('song', 'project', 'Songs To Projects', true);

    On the Album pages, I am using the following call:
    p2p_get_connected($post->ID, 'to');

    As expected, this returns a list of all Songs connected to the Album.

    On the Project pages, using the same call, I only get a list of Songs connected to the Project if there are Songs assigned to the Project. If I'm looking at a Project page that has no Songs connected, p2p_get_connected returns a list of all Songs in the posts table.

    Any ideas what I'm doing wrong?

  2. Modesty
    Member
    Posted 3 years ago #

    which version of the plugin are you using?

  3. jtwg
    Member
    Posted 3 years ago #

    FYI, this is using the current version of 0.6.

  4. Modesty
    Member
    Posted 3 years ago #

    actually, the current version is 0.7 :)
    you will find the link + some basics on usage on the last page of this post:

    http://wordpress.org/support/topic/plugin-posts-2-posts-how-to-add-info-to-connection

  5. jtwg
    Member
    Posted 3 years ago #

    0.7?

    Where are you finding that? Looking at scribu's site, it looks like he still has 0.6 listed as the most recent.

    Thanks for the reference, I'll check it out.

  6. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    actually, the current version is 0.7 :)

    No, 0.7-alpha is the development version.

    The current stable version is indeed 0.6.

    I can't seem to reproduce your problem.

    Keep in mind that p2p_get_connected() doesn't filter by post type. If you want that, you should use get_posts() or WP_Query, with a 'connected_to' arg (examples on my site or in other threads).

    Also, p2p_register_connection_type() takes only 3 arguments (or an array or args).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic