WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Yet Another Related Posts Plugin] if statement (2 posts)

  1. h4ck0r86
    Member
    Posted 6 years ago #

    Is it possible to check and see if there are any related posts?

    I'm displaying the related post results in a new table below the article and would like to wrap it in a PHP if statement that only displays the table if there are articles returned.

    Thanks!

  2. @h4ck0r86 - the easy way to do this is to simply enter what you'd like printed when you have no results into the "Default display if no results" option (including nothing, if you want nothing printed in that case) and similarly play with the before/after related entry/each post settings. The "display code example" on the right side will help you taylor these settings to your needs.

    If you require some PHP in your if block, you can use the function related_posts_exist() which returns true or false and then print related_posts() inside that code block. Remember if you decide to go this route to then turn off the "automatically display related posts" option.

    Thanks for trying out YARPP!

    mitcho

Topic Closed

This topic has been closed to new replies.

About this Topic