WordPress.org

Ready to get started?Download WordPress

Forums

Easy Popular Posts
Error after updating to 2.5.3 (11 posts)

  1. knaber
    Member
    Posted 2 years ago #

    Warning: arsort() expects parameter 1 to be array, null given in .../wp-content/plugins/easy-popular-posts/easy-popular-posts.php on line 83

    Warning: Invalid argument supplied for foreach() in .../wp-content/plugins/easy-popular-posts/easy-popular-posts.php on line 85

  2. ron moss
    Member
    Posted 2 years ago #

    I've got the same problem when I update to version Version 2.5.4 (with WordPress 3.2.1.) :

    Warning: Invalid argument supplied for foreach() in /domains/blog.drweigert.nl/DEFAULT/wp-content/plugins/easy-popular-posts/easy-popular-posts.php on line 85

  3. christopherross
    Member
    Plugin Author

    Posted 2 years ago #

    Ron, could you tell me how you're calling the code?

    I can't seem to replicate the error.

    Chris

  4. knaber
    Member
    Posted 2 years ago #

    Here's how I'm calling mine:

    <?php thisismyurl_easy_popular_posts('count=8&credit=false&show=true'); ?>

  5. ron moss
    Member
    Posted 2 years ago #

    Sorry for my late reply.
    I'm using it as a widget in the main widget area.

  6. Odolyte
    Member
    Posted 2 years ago #

    Same for me : got the "Invalid argument supplied for foreach() in /website.com/wp-content/plugins/easy-popular-posts/easy-popular-posts.php on line 85"

    I've tried both with widget + calling code : same result.

  7. christopherross
    Member
    Plugin Author

    Posted 2 years ago #

    I wish I had an easy answer for you guys but I can't reproduce the error, I'm running the code on http://thisismyurl.com as a widget and when I trie inserting @knaber's code, it works as well.

    If anybody has a test server that the code isn't working in I would love to fix this, please send me an email if you're able to help, I'll take a look right away.

  8. ron moss
    Member
    Posted 2 years ago #

    Ola Chris,

    I re-produced the error:
    on default the 'Display Type:' is set on 'comments'; i've i change this to 'total', the error is gone.
    (I did post a few dummy comments though..)

  9. knaber
    Member
    Posted 2 years ago #

    I can't get it to work. Anyone else find a fix?

  10. bparizek
    Member
    Posted 2 years ago #

    I ran into this as well. Could it be due to the number of comments being counted? I didn't dig into it too deeply, but this change to the code seemed to solve the problem for me (just wrapping the first code block here with an if statement checking if the $myposts variable exists):

    Changed:

    foreach ($myposts as $key=>$value) {
    
    	if (count($popular_posts) <= $ns_options['count'] && $value > 0) {
    		$popular_posts[]->ID = $key;
    	}
    }

    To:

    if ($myposts) {
    
    	foreach ($myposts as $key=>$value) {
    
    		if (count($popular_posts) <= $ns_options['count'] && $value > 0) {
    			$popular_posts[]->ID = $key;
    		}
    	}
    }
  11. christopherross
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks @bparlzek, I still can't replicate the error myself but your code addition makes perfect sense and will hopefully solve some of the problems people are having.

    I've uploaded a new version (2.5.5) and as always, welcome the help!

    Chris

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic