Skip to content

Move 'connected_type' to P2P_Query #61

@scribu

Description

@scribu

The current way of getting connected posts is rather hard to read:

$posts_ids = p2p_type( 'posts_to_pages' )->get_connected( $post_id, array( 'fields' => 'ids' ) )->posts;

Much more familiar would be:

$query = new WP_Query( array(
  'connected_type' => 'posts_to_pages',
  'connected_posts' => $post_id,
  'fields' => 'ids'
) );

$post_ids = $query->posts;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions