Support » Plugin: Yet Another Related Posts Plugin (YARPP) » php code examples?

  • Resolved jamesinealing

    (@jamesinealing)


    Hi, I have YARPP successfully installed on a development site and working fine for standard posts. I’ve been trying to find some reference material though for using php to do some customisations, but even with the readme.txt, a few examples in the forums, oh, and the Wordcamp presentation, I can’t seem to find anything that gives a noob like me the basics. For example what is the difference in use between related_posts() and yarpp_related()?

    The use case that I have is that I want to display related posts for a specific post on a page, rather than the post itself. Both the source post and the related posts will be in a custom post type ‘objects’.

    If I use
    related_posts(array(), $postID, true);
    this works for a standard post ID, but if change the ID to one for a custom post type it says no results (my default config displays both post types)

    So I then tried
    related_posts((array(post_type(array(‘posts’,’objects’)), $postID, true);
    but this returns no results at all, with an ID of either post type.

    Sorry, it may be a very basic mistake on my part, but I’d be grateful for any pointers. Thanks.

    http://wordpress.org/plugins/yet-another-related-posts-plugin/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Sorry, re-typed rather than cut&pasted and that was a very dodgy bit of code which was bound to fail! The second part should be:
    related_posts(array(‘post_type’ => array(‘objects’)), $postID, true);

    OK, I changed that to related_entries and it now seems to work as I wanted. Between noob syntax errors and a bit of front-end caching making me think changes hadn’t worked, I managed to confuse myself completely!

    It would still be great though to have some well-documented code examples, especially as this seems such a powerful and well-featured plugin.

    Plugin Author yarpp

    (@jeffparker)

    Thanks for your feedback. Perhaps we’ll add in future releases.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘php code examples?’ is closed to new replies.