Plugin Author
scribu
(@scribu)
Please post the relevant code (P2P filter + template file) in a http://pastebin.com
Hi Scribu,
Thank you for your answer.
Plugin Author
scribu
(@scribu)
You didn’t post the relevant code, i.e. the code that takes a list of connected posts and loops through them.
Also, I don’t understand how P2P shortcodes are routed to templates. I assume the WP-Views plugin can only generate standard shortcodes, which implies that the code from P2P isn’t used at all.
Edit: what I’m asking for is your version of the code shown here:
https://github.com/scribu/wp-posts-to-posts/wiki/Actions-and-filters
In my functions.php, I’ve copied the shortcode handler from your wiki
And in WP-VIEWS, my template is that one.
From there, p2p shortcodes are calling the bunch of p2p-list-… .php templates that are rendered on that page.
I don’t know if this method is appropriate.
Another question related to this logic, is that I’m interested to retrieve an URL value in a connected custom field, and to inject it into an other shortcode (for a video player). I retrieve the value but I don’t understand yet how I will use it … (the value is just under the picture (below VIDEO title).
I’m sorry if i’m doing dumb stuff … 😛
F
I’ve seen different kind of connexion like
$connected = get_posts( array(
'connected_items' => $zone_posts,
'connected_type' => array( 'CONNECTION_TYPE1', 'CONNECTION_TYPE2', ... ),
'connected_direction' => 'any',
'post_type' => 'any',
'suppress_filters' => false
) );
But i don’t know how to handle that with the shortcode logic. I’m sure that could help to reduce the number of queries.
And after that as for each connexion I need to extract different fields, … I am a little bit lost 🙂
F
Plugin Author
scribu
(@scribu)
Don’t query multiple connection types unless you plan to show them together. The lower query count isn’t worth the extra complexity.
Back on topic: using the_content() works fine for me, since the $post global is changed before each template load.
The only situation that I could imagine where this wouldn’t work would be if you have a post connected to itself.
For the topic the_content(), I understand that it works for you but I don’t know how to handle it in my case.
In the “master template”, I need to place different shortcodes on multiple places. And each places has different elements to render.
| p2p_cp_video_url | current_post_title + current_post_excerpt |
| p2p_cp_sales_arg_content | p2p_cp_free_training_content |
| p2p_cp_testimonial_title + excerpt | xxxx |
So maybe I don’t get the concept of templates for shortcodes, but I can’t figure how to handle different pieces through one connexion and where to place that piece of code.
or maybe the idea to use shortcodes for that kind of template is not a good one?
going straight to standard templates will simplify the process?
Plugin Author
scribu
(@scribu)
going straight to standard templates will simplify the process?
It might. Just don’t start using p2p_list_posts(). 🙂