Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author scribu

    (@scribu)

    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

    (Make sure you’re on the latest dev version – 1.3-alpha3)

    Thread Starter Francois Lamotte

    (@francoislamotte)

    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

    (@scribu)

    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

    (@francoislamotte)

    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

    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

    (@scribu)

    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

    (@scribu)

    Also, the latest dev version is 1.3-alpha3.

    Thread Starter Francois Lamotte

    (@francoislamotte)

    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

    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

    The second shortcode has a h2 header that is missing in the display.

    The display looks like :

    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

    (@scribu)

    Ok, so it works. The “warning” is from the var_dump(), which you can remove now.

    Thread Starter Francois Lamotte

    (@francoislamotte)

    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.