• 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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • which version of the plugin are you using?

    Thread Starter jtwg

    (@jtwg)

    FYI, this is using the current version of 0.6.

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

    https://www.ads-software.com/support/topic/plugin-posts-2-posts-how-to-add-info-to-connection

    Thread Starter jtwg

    (@jtwg)

    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.

    Plugin Author scribu

    (@scribu)

    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).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Posts 2 Posts retrieving all records in connected table when no match’ is closed to new replies.