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

  1. jtwg
    Posted 3 years 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!


  2. scribu
    Plugin Author

    Posted 3 years 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

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.