WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] How to count number of connections? (4 posts)

  1. Ethan Shaw
    Member
    Posted 3 years ago #

    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/

  2. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    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.

  3. Ethan Shaw
    Member
    Posted 3 years ago #

    Thank you for considering programming it in!

  4. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    I didn't do anything. It comes from WordPress. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic