WordPress.org

Support

Support » Plugins and Hacks » WordPress Popular Posts » [Plugin: WordPress Popular Posts] Add spaces to post_start attribute

[Plugin: WordPress Popular Posts] Add spaces to post_start attribute

  • Hello,

    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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
    li

    Any ideas?

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

    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?

    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')) {
    				ob_start();
            			$args = 'limit=5&range=weekly&order_by=views&pages=0&stats_comments=0';
    					wpp_get_mostpopular($args);
    				$popular = ob_get_clean();
    
    				$popular = explode('</li>', $popular);
    				$popular_counter=1;
    
    				foreach ($popular as &$p)	{
    					$p = str_replace('<li>','<li class="popular popular-'.$popular_counter.'">',$p);
    					$popular_counter++;
    				}			
    
    				$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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WordPress Popular Posts] Add spaces to post_start attribute’ is closed to new replies.
Skip to toolbar