WordPress Popular Posts
[Plugin: WordPress Popular Posts] Add spaces to post_start attribute (4 posts)

  1. dancasas
    Posted 5 years ago #


    I am trying to tune the plugin through the short code [wpp], but when I am using strings with spaces as a value of any of the attributes, everything crashes.

    For example, I would like to set the post_start parameter as follows

    [wpp post_start="<div class="popular_entry">" post_end="</div>"]

    and I believe it chrashes due to the space between div ans class, and maybe also due to the extra " I am using.

    I there any way to fix this? Thanks a lot!

  2. maorb
    Posted 5 years ago #

    Have you find a solution to this?
    In my case, I use the template function wpp_get_mostpopular with some args. All args are well working, except the post_start and post_end - it just ignores everything I try to write as post_start, I tried to put a string with no spaces, but didn't help - this attribute just won't expand and stays as

    Any ideas?


  3. dancasas
    Posted 5 years ago #

    I haven't found any solution so far... It looks to me that this is a common issue to anyone trying to play with this plugin, but no one seems to have solved the problem.

    More ideas anyone?

  4. maorb
    Posted 5 years ago #

    Well, I've just wrote couple lines of code to handle this.
    If you use the template tag and not the shortcode, you can use these:

    <?php if (function_exists('wpp_get_mostpopular')) {
            			$args = 'limit=5&range=weekly&order_by=views&pages=0&stats_comments=0';
    				$popular = ob_get_clean();
    				$popular = explode('</li>', $popular);
    				foreach ($popular as &$p)	{
    					$p = str_replace('<li>','<li class="popular popular-'.$popular_counter.'">',$p);
    				$popular = implode('</li>', $popular);
    				$popular = str_replace('<ul>', '<ul class="popular-posts">', $popular);
    				echo $popular;
    			} ?>

    The $args line, define the args I want, except of the post_start.
    The line that starts with $p = str_replace ... will replace any li with li with class popular and also class popular-1/popular-2 etc.. so you can later style these.

    Hope it will help you and others.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress Popular Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic