Support » Plugin: Posts 2 Posts » [Plugin: Posts 2 Posts] shortcodes to display relationships

  • Resolved Francois Lamotte


    Hello I’m a complete newbie.

    I’m interested to understand through an example if possible, how it could be possible to use shortcodes to insert relationships in templates and post/page objects.

    I’m currently working with WP-Views who does a really nice job based mainly on shortcodes. And Post to Post works like a charm to connect Custom_Post.

    So I would be interested to manage such shortcodes.

    Thank you for your ideas and support.



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


    Hm… so a P2P shortcode would list connected items for the post it’s inserted in. I guess it could look like this:

    [p2p_connected ctype=posts_to_pages]

    Yep, that would be useful.

    yes. I’m trying something like this (inspired by this example )

    But you would be more productive, if you could list the different cases (and maybe manage them in a single file).

    For example, in a project I need to display more than Title + hyperlinks (one listing title+excerpt, or title+full_post_body )

    [p2p ctype=post_to_page display=title mode=list_ul]
    [p2p ctype=post_to_page display=title+body mode=table]

    You will say that display would be too complex (if someone wants to retrieve a thumbnail, a custom_field, …-

    The mode could be the way to display your list : UL, OL, Grid, Table, …

    Thank you for your feedback.

    Here is what I’m writing (not yet tested).

    [44 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Plugin Author scribu


    This is what’s implemented in the development version (1.3-alpha2) so far:

    [p2p_connected type=posts_to_pages]
    [p2p_related type=posts_to_pages mode=ol]

    If you want excerpts, tables etc., just implement your own shortcode. It’s not hard.

    Plugin Author scribu


    I suppose a mode=table would make sense if it displayed all the connection fields that you would see in the admin box.

    Oh Thank you very much. I’ll test it really soon. And I’ll try to get some feedback.

    Hi Scribu,

    Could you please send me your 1.3-alpha2 release?

    The link provided above is toward the 1.2 release.

    Or give a link to download it? I’m interested to test those shortcodes in a project. So instead of reinventing the wheel (a square wheel 😛 ), I would test it for you.

    Best regards,


    I guess it is the github version?

    I’ll give a look 🙂

    Plugin Author scribu


    Yes, you could download it from github, but the link I gave you does point to 1.3-alpha2.

    Sorry (my colleague that receive the link was claiming that shortcodes were not in that version … so instead of verifying it, I was searching for it)

    I’ve tryied the Github version (including 2 others projects links with SCB framework and mustache) and it works smoothely.

    Thank you very much.



    Hi guys,

    what if I’d like to get a simple link list?

    I mean a list of the connected post not formatted in an ordered/unordered list but just a list of comma-separated links?

    I thought it’s something about the “mode” attribute in the shortcode but I can’t find any detailed information about it on the plugin’s home page.

    Can you help me?


    Francois Lamotte


    Hi Carlo,

    The mode attribute is just there to point to the right piece of code.

    You could create different variations (table, list, raw, …) and call the one you need following your context.




    I finally solve my issue,
    thanks Scribu and Francois…

    I really appreciate your help and your work!


    Plugin Author scribu


    It would be nice if you could share the code you used, for other users that might be trying to do the same thing.



    Well actually I don’t have really much to share since I solve my issue trough css 🙁

    My problem was that I put the related list inside a <p></p> element and when I run the page the related list broke the got and display on a new line.

    So I simply use the mode=list and work on css to put label and related list inline.

    That’s it…. a not-so-brilliant workaround at all.

    But now I see that scribu add an inline mode in the dev version of the plugin. Think that this could be a great solution indeed!

    Thanks again!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Posts 2 Posts] shortcodes to display relationships’ is closed to new replies.