WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] WP_Query vs. get_posts for p2p_distribute_connected (2 posts)

  1. jtwg
    Member
    Posted 1 year ago #

    I was reading the p2p docs for retrieving all connected posts using the WP_Query object. Normally the way I pull out connected items to a post is via shortcodes that serve as placeholders in the post content to show the connected items.

    Typically I've used get_posts in my shortcodes for retrieving the connected posts, but now that I am building more complex shortcodes that not only retrieve posts connected to the current post, but also posts connected to the connected posts I'm concerned about database queries multiplying unnecessarily.

    If I'm reading the docs correctly, it seems that I need the WP_Query object in order to make use of the p2p_distribute_connections functionality. Is that correct? Or will this also work using get_posts?

    Thanks for the awesome plugin!

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    Just use WP_Query. get_posts() is a wrapper around it anyway.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.