• I’m sorry to bring this issue back up again, but the previous topic was closed without a decent fix and I think there might be others with the same problem and this topic actually provides a working and decent fix. Perhaps the plugin author can also implement this fix?

    First of all, thanks to the plugin author for creating and developing this wonderful plugin.
    It’s a really wonderful plugin and with this tiny fix, it will be perfect!

    First let me explain the exact problem:
    When the list of last viewed items has reached the limit that you can set in the settings (Number of posts to show, for example 5), it can break your website layout. The reason for this is, is that when the limit is reached – in my case 5 – the closing ul and closing div are missing. This is not the case as long as the limit hasn’t been reached.

    Why are this closing ul and closing div missing?
    Because there is a tiny mistake in the php code of the plugin. A big big big thank you to my husband who helped me fix this problem.

    Go to the plugin folder posts-viewed-recently, open the php file recent_viewed_posts.php
    Go to line 164, there you will find this:

    if($count >= $number) return;

    This is the faulty line: when the condition is met, the line 214

    <?php if($count > 0) echo '</ul>'. $after_widget; ?>

    doesn’t get executed anymore, resulting in not displaying both closing ul and closing div tags (which is in the variable $after_widget).

    Here’s the fix:
    replace line 164, so this line:
    if($count >= $number) return;

    With this:

    if($count >= $number){
       if($count > 0){
          echo '</ul>'.$after_widget;
       }
       return;
    }

    This solved my problem entirely. So if you’re having this problem, please try this fix!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thanks for this fix @elvesatwork. This fix works great in a site where I used this plugin some time ago. Hadn’t noticed the missed HTML tag oversight before. Not sure how I happened to miss that.

    Anyway, I am not the developer of this plugin but I have forked the plugin on GitHub from the WP GitHub mirror and updated the plugin to version 1.2.1 for the purpose of adding in your fix for those who want to benefit from it. The download is here https://github.com/VR51/posts-viewed-recently

    Will probably add a few more changes at some point. Thanks again!

    Plugin Author Amit Sonkhiya

    (@amitaits)

    Hello @elvesatwork

    I’m sorry to not being here for long time and appreciate you much and @leehodson to notify about us this issue and the solution.

    We will verify & update the plugin soon, if needed. Thanks alot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Re: Missing close div causes html to break’ is closed to new replies.