WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] templates for p2p_list_posts (3 posts)

  1. Manuel Schmalstieg
    Member
    Posted 2 years ago #

    Congratulations for this awesome plugin. It's already revolutionizing my WordPress-as-a-CMS workflow.

    I would like to ask for some information regarding the "templates" that we can supposedly define for the p2p_list_posts() function.

    A reference to such templates is included in the function's code, in /core/api.php ... but there is no info yet in the official wiki: https://github.com/scribu/wp-posts-to-posts/wiki/Using-p2p_list_posts%28%29

    So I guess this feature will evolve with coming updates?

    My practical use case: at some places of my theme, I want to output a list of connected posts without the hyperlink linking to the post. Just the title. While I can define "before" and "after" markup, there seems to be no easy way to disable the hyperlink.

    For now I will simply modify the function in /core/api.php, or create a similar function. But it would be good to know more about the use of those templates.

    Another thing: I spent some time trying to apply the code given in "Looping The Loop" inside multiple loops built with WP_Query, which wasn't giving me the expected results. Finally I understood that I should use query_posts for that, and all worked fine.
    The "Looping The Loop" article might include a little hint, for the noobs among us ;)

    Thanks again for the great work!
    PS: I created German language files, will send them your way.

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

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    p2p_list_posts() is just a utility to avoid using a normal Loop. I'm not even sure if I should keep it around.

    As for the 'template' parameter, you would use it like this:

    p2p_list_posts( $connected, array( 'template' => 'some-template.php' ) );

    And in your theme, you would have to have a file called some-template.php.

  3. Manuel Schmalstieg
    Member
    Posted 2 years ago #

    Thanks Scribu for the splendid x-mas holiday support.
    I will give the template parameter a try.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic