Title: [Plugin: Posts 2 Posts] shortcodes example for connected post of connected post
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] shortcodes example for connected post of connected post

 *  Resolved [Francois Lamotte](https://wordpress.org/support/users/francoislamotte/)
 * (@francoislamotte)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcodes-example-for-connected-post-of-connected-post/)
 * Hi Scribu,
 * I’ve got a similar case of that entry :
 * [http://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts?replies=7](http://wordpress.org/support/topic/plugin-posts-2-posts-get-connected-posts-of-connected-posts?replies=7)
 * Let’s say that I got :
 * – A Training module
    — linked to Chapters — linked to Courses
 * Sometimes I need to use it in a Widget Sidebar (as a menu for that Training module),
   and sometimes in a display of page.
 * But I’m interested to manipulate it through shortcodes.
 * And for the display of the page, as I work with the WP-VIEWS templating system,
   I need to paste shortcodes.
 * Question: if you’re available for that kind of works, I could pay you of course.
   I could give you my email address if you want to.
 * Regards,
 * François
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

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

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcodes-example-for-connected-post-of-connected-post/#post-2706484)
 * Sorry, I am not interested in freelance work at this time.
 * Note that there already is a P2P widget and that you can manipulate both the 
   widget and the shortcode output through a filter:
 * [https://github.com/scribu/wp-posts-to-posts/wiki/Actions-and-filters](https://github.com/scribu/wp-posts-to-posts/wiki/Actions-and-filters)
 * (Make sure you’re on the latest [dev version](http://downloads.wordpress.org/plugin/posts-to-posts.zip)–
   1.3-alpha3)
 *  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-shortcodes-example-for-connected-post-of-connected-post/#post-2706587)
 * Hi Scribu,
 * I’m maybe stupid, but I can’t figure out how to use your code in the link above.
 * I’ve made a page : p2p-list-contacts_to_companies.php
 * Your fonction to add the filter is inserted in the **functions.php **template
   just below the connexion description to register the relationship.
 * And when I try to display the shortcode, this is always the default view that
   is displayed and the not the filter.
 * <h2>P2P Connected</h2>
    [p2p_connected type=contacts_to_companies]
 * <h2>P2P related (OL)</h2>
    [p2p_related type=contacts_to_companies mode=ol]
 * Do I miss something, or place the code on the wrong templates?
 * Thank you for your help.
 * F
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcodes-example-for-connected-post-of-connected-post/#post-2706589)
 * After this line:
 *     ```
       $template = locate_template( 'p2p-list-' . $ctype->name . '.php' );
       ```
   
 * add
 *     ```
       var_dump( $template );
       ```
   
 * Also, are you sure you have the latest dev version?
 *  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-shortcodes-example-for-connected-post-of-connected-post/#post-2706592)
 * Thank you for your answer.
 * yes for the latest dev version => Version 1.3-alpha2
 * With WP-DUBUG, I’ve got those messages:
 * >  Warning: Can’t determine direction for ‘contacts_to_societes’ type. in /Applications/
   > MAMP/htdocs/prospection/wp-content/plugins/posts-to-posts/core/type.php on 
   > line 99
   > Fatal error: Call to a member function render() on a non-object in /Applications/
   > MAMP/htdocs/prospection/wp-content/plugins/posts-to-posts/core/shortcodes.php
   > on line 48
 * Here is my code in functions.php : [http://pastebin.com/NqkFep9x](http://pastebin.com/NqkFep9x)
 * And the template filter (p2p-list-contacts_to_societes.php) contains your sample:
 *     ```
       <div>
         <?php the_post_thumbnail(); ?>
         <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
       </div
       ```
   
 * Thank you for your time.
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcodes-example-for-connected-post-of-connected-post/#post-2706594)
 * There’s one more piece of the puzzle: where are you inserting the shortcode?
 * It uses the `$post` global to get the list of connected items.
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcodes-example-for-connected-post-of-connected-post/#post-2706596)
 * Also, the latest dev version is 1.3-alpha3.
 *  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-shortcodes-example-for-connected-post-of-connected-post/#post-2706600)
 * Ok things are different with the latest 1.3-alpha3 🙂 but there’s still a warning…**
   string(111)**
 * **Place where shortcode was inserted**
 * On Template for Custom Post linked ( contact, societe ), it always displays the“
   standard” view of the shortcode (with 1.3-alpha2). It changes now with 1.3-alpha3
 * I got something like this (1.3-alpha2)
 * [https://skitch.com/francoislamotte/8i23e/post2post-shortcode-filter-problem](https://skitch.com/francoislamotte/8i23e/post2post-shortcode-filter-problem)
 * And it was my fault (for the errors above) to insert the shortcode in a POST.
   As I was searching why the FILTER was not loading, I’ve tried this without thinking
   about the logic of the code (which object was loaded, …) 😛
 * **NOW WITH THE 1.3-alpha3**
 * The filter template is well loaded/parsed but I get a warning (WP-Debug) and 
   an HTML tag is missing.
 * **The alert message**
 * >  string(111) “/…/wp-content/themes/wpbootstrap-lessified/p2p-list-contacts_to_societes.
   > php” string(111) “/Applications/MAMP/htdocs/prospection/wp-content/themes/wpbootstrap-
   > lessified/p2p-list-contacts_to_societes.php”
 * **And the template (shortcodes) looks like :**
 * >  <h2>Profil Contact</h2>
    1. Nom: [types field=”nom”][/types]
    2. Prénom: [types field=”prenom”][/types]
    3. Titre: [types field=”titre”][/types]
 * <h2>P2P Connected</h2>
 * [p2p_connected type=contacts_to_societes]
 * <h2>P2P related (OL)</h2>
 * [p2p_related type=contacts_to_societes mode=ol]
 * [https://skitch.com/francoislamotte/8i3d6/shortcode-template](https://skitch.com/francoislamotte/8i3d6/shortcode-template)
 * The second shortcode has a h2 header that is missing in the display.
 * **The display looks like :**
 * [https://skitch.com/francoislamotte/8i3rx/shortcode-display](https://skitch.com/francoislamotte/8i3rx/shortcode-display)
 * **The Filter code :**
 *     ```
       <br />
       <div><br />
          <h3>This comes from the <strong>FILTER</strong></h3><br />
         <?php the_title(); ?><br /> # with links
       </div</p>
       <p>
       ```
   
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcodes-example-for-connected-post-of-connected-post/#post-2706601)
 * Ok, so it works. The “warning” is from the var_dump(), which you can remove now.
 *  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-shortcodes-example-for-connected-post-of-connected-post/#post-2706602)
 * Oh great thank you …

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

The topic ‘[Plugin: Posts 2 Posts] shortcodes example for connected post of connected
post’ 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/)

 * 9 replies
 * 2 participants
 * Last reply from: [Francois Lamotte](https://wordpress.org/support/users/francoislamotte/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-posts-2-posts-shortcodes-example-for-connected-post-of-connected-post/#post-2706602)
 * Status: resolved