-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List all posts of a custom post type ordered by the count of connections they have to another cpt #562
Comments
Hello, I have the same issue. Have you discovered a way to query for posts based on the number of connections? This would be most useful for querying for user to posts connections to determine the most popular posts. |
No, unfortunately not. I couldn't find a way to query the count of relations/connections. |
OK, thanks for the reply. I figured their probably isn't a way to do this. So I built a workaround, I created a meta field in functions.php called 'p2p_post_counter' and then wrote a small plugin with functions that increment and decrement that field every time a connection is made. I only need this data for user to post connections, so in my case I added code to the plugin Restful P2P which is primarily for that type of connection. Now when a connection is made or a connection is deleted it calls the function that updates the counter. I could elaborate more if anyone is interested but the concept is pretty simple. The only drawback is it's not retroactive so to speak, so prior connections obviously won't be counted. |
Wow. That’s neat. Thanks for posting. |
I have two cpts "partner" and "event". Now I want to list all "partners" according to the number of connections they have to "events". How do I query the connections to get the count?
PS: Plus it would be awesome to display the actual count of connections alongside the cpt (in brackets).
The text was updated successfully, but these errors were encountered: