WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Posts 2 Posts] How to count number of connections?

[Resolved] [Plugin: Posts 2 Posts] How to count number of connections?

  • Hi Scribu,

    Thank you for such an awesome plugin. I have come to use it in every project I do now. 🙂

    I have read through your site, the wiki and the source files for Posts 2 Posts but I cannot figure how to count the number of connections? I tried using php’s count function and wp_count_posts in varying combinations but to no avail.

    Do you have any thoughts?

    Thank you so much for your time!

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author scribu
    Member

    @scribu

    WP_Query actually has a variable for this:

    $connected = new WP_Query( array(
    	'post_type' => 'page',
    	'connected_from' => $post->ID
    ) );
    
    echo $connected->found_posts;

    That will output the total number of connected posts found.

    Thank you for considering programming it in!

    Plugin Author scribu
    Member

    @scribu

    I didn’t do anything. It comes from WordPress. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: Posts 2 Posts] How to count number of connections?’ is closed to new replies.