Support » Plugin: Posts 2 Posts » Multisite version of WP

  • Resolved non_human

    (@non_human)


    Hi!
    Thanks for the great plug in, by the discussion I can see that it is something I really need for my site, but I have a problem using it on my network word press install (WP version: 3.1.2, PHP version: 5.2.14).

    #1. I have two custom post types ‘artist’ and ‘event’, I created relation between them and meta boxes appeared in the admin UI. But connection disappears after I update artist or event.
    #2. I want to query related artists in the event admin part and add meta box where related artist’s title will become event’s custom field key and then I can have other information added there as custom field value.
    For now, when I copy paste the display code:
    `$connected = new WP_Query( array(
    ‘post_type’ => ‘artist’,
    ‘connected_to’ => get_queried_object_id()
    ) );

    echo ‘<ul>’;
    while( $connected->have_posts() ) : $connected->the_post();
    echo ‘<li>’;
    the_title();
    echo ‘</li>’;
    endwhile;
    echo ‘</ul>’;

    wp_reset_postdata();`

    it shows ALL the artists. I assume it’s because of the issue #1, that the plugin doesn’t save the relations.

    Do you have any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author scribu

    (@scribu)

    Note that get_queried_object_id() will only work when called from your theme’s single.php or page.php file.

    In the admin, you will have to pass the exact post ID that you want. It’s up to you to figure out how to get that ID. $GLOBALS['post']->ID might work.

    But connection disappears after I update artist or event.

    And this happens using the default metabox in version 0.7?

    Thread Starter non_human

    (@non_human)

    Thanks for a quick answer!
    yes, plugin version is 0.7 network activated. adding connections through the metabox that appeared in the post edit/add admin after I registered a connection: http://d.pr/Dwx1
    But after I hit “update” post or refresh page the event is gone from the list of added connections.

    In the admin, you will have to pass the exact post ID that you want. It’s up to you to figure out how to get that ID. $GLOBALS[‘post’]->ID might work.

    Yes, I used $_GET['post'] but I put it inside get_queried_object_id() and that was a mistake I guess.

    Is this a correct usage:

    `$connected = new WP_Query( array(
    ‘post_type’ => ‘artist’,
    ‘connected_to’ => $_GET[‘post’]
    ) );`
    Now the list is empty, and I think it’s correct as no connection has been saved in the DB.

    Thank you again for your help. I’m developing in a tight deadline so your help is greatly appreciated!

    Thread Starter non_human

    (@non_human)

    this might help!
    I have a WP network thus all my blogs have prefix: wp_(blog id)_tablename. So here is the MySQL query I get when I look for connected artists:
    SELECT SQL_CALC_FOUND_ROWS wp_9_posts.*, wp_9_p2p.* FROM wp_9_posts INNER JOIN wp_9_p2p WHERE 1=1 AND wp_9_posts.post_type
    When I look in the DB, there’s only wp_p2p and wp_p2pmeta tables.

    Plugin Author scribu

    (@scribu)

    Ah, yes. You will need to install this plugin:

    http://wordpress.org/extend/plugins/proper-network-activation/

    and then re-activate P2P.

    Is this a correct usage:

    $connected = new WP_Query( array(
    'post_type' => 'artist',
    'connected_to' => $_GET['post']
    ) );

    Yes, as long as $_GET['post'] contains the expected post id.

    Thread Starter non_human

    (@non_human)

    perfect! thanks!!
    I have one more question, but I will post it separately 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multisite version of WP’ is closed to new replies.