• In my application I need to get the the connected posts and metadata associated to a connection using only p2p_id.

    I can get the meta data using function p2p_get_meta(...) But could n’t find any function available to get the connected posts / users.
    I mean to say, is there any function like: p2p_get_connected( <p2p_id> ) That returns from and to connections or something similar to that.

    Please Help.!!

    https://www.ads-software.com/plugins/posts-to-posts/

Viewing 1 replies (of 1 total)
  • Thread Starter sptutusukanta

    (@sptutusukanta)

    Hi All,
    I’ve just figured out a work around for this and wanted to share with you.

    function ufxdGetP2PConnection( $p2pID, $connType = NULL ){
        global $wpdb;
        $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}p2p WHERE p2p_id = %d", $p2pID );
        if( !empty( $connType ) ) $sql .= $wpdb->prepare( " AND p2p_type = %s", $connType );
        $conn = $wpdb->get_row( $sql );
        if( !empty( $conn ) AND !is_wp_error( $conn ) ){
            $output = new stdClass();
            $output->from = get_post( $conn->p2p_from );
            $output->to = get_post( $conn->p2p_to );
            $output->conn_type = $conn->p2p_type;
            return $output;
        }
        return NULL;
    }

    Please Mark this resolved if I’m right. Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Get Connected Posts By p2p_id’ is closed to new replies.