• Hi,

    Currently in the plugin, when there are no posts to show for the daily range.

    The following code is activated.

    if ( !is_array($mostpopular) || empty($mostpopular) ) {
    				$content .= "<p><a href=\"/videos\">".__('Looking for videos? Click here', 'wordpress-popular-posts')."</a></p>"."\n";
    			}

    I noticed it looked strange on my site, so I want to make if there is no content in a range, it will display the most popular posts from yesterday. How do I do that?

    http://wordpress.org/extend/plugins/wordpress-popular-posts/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi jaggreene,

    Currently, there’s no way to achieve this. Earlier versions of WordPress Popular Posts had an undocumented “yesterday” option for the Time Range feature that allowed users to get the most popular posts from yesterday only. However, the daily option has been replaced with the last 24 hours so the yesterday option doesn’t work anymore.

    Thread Starter jaggreene

    (@jaggreene)

    Hi Hector,

    Thanks for the answer.

    How do I change the above code then to show the most popular posts from the week (instead of yesterday) when $mostpopular is empty?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Here’s a modified copy of my plugin. I didn’t test it, but it should do what you want.

    Be aware that this is a hack, and once WordPress Popular Posts is updated again all these changes will be lost. Modifications were made on the get_popular_posts function only, so you probably want to save a copy of that for future reference.

    Thread Starter jaggreene

    (@jaggreene)

    Hi,

    thanks for the code. $mostpopular just shows up blank instead of displaying the week’s video posts.

    I think my best option now is to just have an html notice when $mostpopular is blank directing them to a search page.

    I had

    if ( !is_array($mostpopular) || empty($mostpopular) ) {
    				$content .= "<p><a href=\"/videos\">".__('Looking for videos? Click here', 'wordpress-popular-posts')."</a></p>"."\n";
    			}

    I also tried

    if ( !is_array($mostpopular) || empty($mostpopular) ) {
    				$mostpopular .= "<p><a href=\"/videos\">".__('Looking for videos? Click here', 'wordpress-popular-posts')."</a></p>"."\n";
    			}

    neither seemed to work

    Thread Starter jaggreene

    (@jaggreene)

    Hi,

    Any help on this would be appreciated

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WordPress Popular Posts] If mostpopular is empty, show yesterday's posts’ is closed to new replies.