Title: [Plugin: Posts 2 Posts] shortcode, filters and templates
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] shortcode, filters and templates

 *  Resolved [Francois Lamotte](https://wordpress.org/support/users/francoislamotte/)
 * (@francoislamotte)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcode-filters-and-templates/)
 * Hi Scribu,
 * With the new logic of filters, I was wondering how it was possible to manage 
   different templates for the same connexion.
 * Maybe my following suggestion is out of scope and already working. As I’m not
   a dev, pardon my lack of knowledge on the way to code it.
 * **Current Shortcodes**
 * > [p2p_connected type=posts_to_pages]
   > [p2p_related type=contacts_to_societes mode=ol]
 * Following my context, I need different display:
    1. Same view but different display
    2. Different elements extracted from the linked posts
 * **1. Same view : different display**
    - List unordered
    - List ordered
    - Table
    - Grid
    - …
 * If we took the `mode=` attribute we could point to template
 * `p2p-list-posts_to_pages.php`
    - `p2p-list-posts_to_pages-ol.php`
    - `p2p-list-posts_to_pages-ul.php`
    - `p2p-list-posts_to_pages-table.php`
    - `p2p-list-posts_to_pages-grid.php`
 * maybe more efficient with a conditional logic inside the same template 🙂
 * **2. Different elements extracted from the linked posts**
 * Sometimes, you need only a Title+Link, but elsewhere you want Title+Link+Excerpt
   +Thumbnail, …
 * Same query but different elements to display.
 * Or another more complex query
 * **Post** = p2p link >> **Pages** = p2p link >> **Custom Posts**
 * Example of display :
 * Page #1 (title+link)
    — Custom-Post #1.1 (title+link+thumbnail) // Display in
   a table — CP #1.2 Page #2 — CP #2.1 — CP # 2.2 — CP # 2.3
 * Here maybe we would need to point to different templates … but how to point them
   i the shortcode
 * [p2p_connected type=posts_to_pages template=p2p-list-posts_to_pages-view_2]
 * Once again, thank you for your guidance.
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Francois Lamotte](https://wordpress.org/support/users/francoislamotte/)
 * (@francoislamotte)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcode-filters-and-templates/#post-2710032)
 * I’ve sent you a donation for your timely support 😉
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcode-filters-and-templates/#post-2710048)
 * Thanks 🙂
 * Yeah, it makes sense to have access to the `$mode` parameter from.
 * I’ve updated the code example on the wiki:
 * [https://github.com/scribu/wp-posts-to-posts/wiki/Actions-and-filters](https://github.com/scribu/wp-posts-to-posts/wiki/Actions-and-filters)
 * This is the major difference:
 *     ```
       $template = locate_template( "p2p-{$mode}-{$ctype->name}.php" );
       ```
   
 * So the template file would look like this:
 *     ```
       p2p-grid-posts_to_pages.php
       ```
   
 * The latest [dev version](http://downloads.wordpress.org/plugin/posts-to-posts.zip)
   is now 1.3-beta.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Posts 2 Posts] shortcode, filters and templates’ is closed to
new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [scribu](https://wordpress.org/support/users/scribu/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcode-filters-and-templates/#post-2710048)
 * Status: resolved