Connecting The Dots
Cristi Burcă
Lisbon, Sep. 2012
Cristi Burcă
Lisbon, Sep. 2012
* posts = posts, pages, attachments, CPTs
function page_contributors_ctype() {
p2p_register_connection_type( array(
'name' => 'page_contributors',
'from' => 'page',
'to' => 'user',
'duplicate_connections' => true,
'fields' => array(
'contribution' => 'Contribution'
)
) );
}
add_action( 'p2p_init', 'page_contributors_ctype' );
function get_contributed_pages( $user_id ) {
$query = new WP_Query( array(
'connected_type' => 'page_contributors',
'connected_items' => $user_id
) );
return $query->posts;
}
function get_contributing_users( $page_id ) {
return get_users( array(
'connected_type' => 'page_contributors',
'connected_items' => $page_id
) );
}
wp_postmeta
wp_terms
wp_term_relationships
wp_p2p
wp_p2pmeta