Plugin Author
scribu
(@scribu)
Technically speaking, this is not a tree, but a directed graph. And those are not “ancestors”. An ancestor is a post that has it’s ID as the value of another’s post_parent column.
I agree that in some cases it would probably be faster to use a single SQL statement, but I’m having a hard time imagining an intuitive API for it.
Plugin Author
scribu
(@scribu)
Maybe something like this:
$query = new WP_Query( array(
'connected_chain' => array( 'series_to_seasons', 'seasons_to_episodes', 'episodes_to_actors' )
'connected_items' => $serie_id
) );
Each element in the 'connected_chain' array would be a connection type.
Thanks for a once again very quick reply, scribu! Of course you’re right about the terminology.
That initial draft using “connection chains” looks pretty good. Here’s another thought: Would it be possible to simply add a single new parameter like ‘include_indirect_connections=true’ to the current API? So you only need this param plus “from” and “to”? I don’t know the inner workings of the plugin, but if technically possible, this way seems very intuitive.
Of course it would also be nice to (optionally) be able to also specify some “exclude” filters, so posts connected via a certain post type would be excluded. 🙂
Plugin Author
scribu
(@scribu)
Would it be possible to simply add a single new parameter like ‘include_indirect_connections=true’ to the current API?
It would be ambiguous. What if you have several connection types containing the ‘episode’ post type? I think passing the connection types explicitly is the sweet spot between ease of use and preciseness.
You’re free to implement 'include_indirect_connections=true' yourself using the ‘parse_query’ hook, as a shortcut which expands to a commonly used chain.
Of course it would also be nice to (optionally) be able to also specify some “exclude” filters, so posts connected via a certain post type would be excluded. 🙂
If you define your connection types appropriately, you shouldn’t need this. Plus, you have the ‘p2p_connected_args’ hook for further filtering.