WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] shortcodes to display relationships (16 posts)

  1. Francois Lamotte
    Member
    Posted 2 years ago #

    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.

    Regards

    F

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. Francois Lamotte
    Member
    Posted 2 years ago #

    yes. I'm trying something like this (inspired by this example http://www.billerickson.net/shortcode-to-display-posts/ )

    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]

  4. Francois Lamotte
    Member
    Posted 2 years ago #

  5. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  6. scribu
    Member
    Plugin Author

    Posted 2 years ago #

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

  7. Francois Lamotte
    Member
    Posted 2 years ago #

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

  8. Francois Lamotte
    Member
    Posted 2 years ago #

    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 :-P ), I would test it for you.

    Best regards,

    --
    Fran├žois

  9. Francois Lamotte
    Member
    Posted 2 years ago #

    I guess it is the github version?

    I'll give a look :-)

  10. scribu
    Member
    Plugin Author

    Posted 2 years ago #

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

  11. Francois Lamotte
    Member
    Posted 2 years ago #

    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.

  12. carletto0282
    Member
    Posted 1 year ago #

    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?

    Thanks
    Regards
    Carlo

  13. Francois Lamotte
    Member
    Posted 1 year ago #

    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.

  14. carletto0282
    Member
    Posted 1 year ago #

    Yep

    I finally solve my issue,
    thanks Scribu and Francois...

    I really appreciate your help and your work!

    Regards
    Carlo

  15. scribu
    Member
    Plugin Author

    Posted 1 year ago #

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

  16. carletto0282
    Member
    Posted 1 year ago #

    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!
    Bye

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic