WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] Use of "custom php template" breaks the website (4 posts)

  1. Merchenman
    Member
    Posted 1 year ago #

    Using the custom php code and your own template file should mean, that only this will be ptinted and nothing more, but YARPP still adds a few more things which breaks the design.

    Something I don't understand, before the template file appears a number, either 1, 2 or 3, which I don't even know where it comes from, but the design breaks, because YARPP is closing one div container too much, so as a workaround a had to add an opening div inside the YARPP template file, which solved it, but if there are no related posts, this is not necessary. Weird things.

    I had a look at the code, "class-core.php" shows the problem. Line 818 should only use the contens of the template-file and not append to the previous. Instead of
    $output .= ob_get_contents();
    it should be
    $output = ob_get_contents();

    Next problem is the closing div which is always appended in line 844, which is not necessary if I use my own template. Should be put in an if-statement, which doesn't print it with a template.

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

  2. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    I'm sorry that this has affected you. The addition of <div class="yarpp-related"> around YARPP's output is a feature, which I believe helps make CSS styling simpler in 90% of cases... it does require that the template only produce a "subtree" of the DOM. Perhaps your design is a bit more complicated and this is problematic.

    What exactly are you trying to do with YARPP, such that having a <div/> wrapped around the output is a problem? Can you post your custom template code and/or link to your site here so I can see what you're trying to do?

  3. Merchenman
    Member
    Posted 1 year ago #

    Ok, looking into this a little bit further, many weird things happened and so on, but I found out that the problem is very simple.

    I used my YARPP custom template since a long time and even with older YARPP Versions and it always worked perfectly. The problem is, that my YARPP template uses a variable called $output which you are using in the class-core.php which are just interfering. I guess that's the only variable that you are not allowed to use in your custom YARPP template.

  4. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, yes. Use of the $output variable was never documented, but was silently supported for a while. Not any more.

    You want to just print whatever output you want in your custom template file, and YARPP will wrap that HTML in a <div> and return it. Just don't touch that $output variable. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic