WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
[resolved] [Plugin: WordPress Popular Posts] Issue with Conditional Formatting tags (5 posts)

  1. alexsteninge
    Member
    Posted 3 years ago #

    Hi,

    I run the blog/recipe page http://www.stjerneskud.eu with the test site http://stjerneskud.steninge.eu. I recently downloaded this awesome plugin and played around with setup and styling on the test site.

    I wanted the plugin to display the information differently then the standard setup, i.e. I wanted it to display title-image-excerpt. I checked the Use Conditional Formatting checkbox and added the following code AA {title} BB {image} CC {summary} DD. I tried many combos and eventually added the AABBCCDD just to see where the text output is located. It still "just" displays image-title-excerpt.

    Any help on possible work-arounds or fixes or my setup errors is much appreciated.

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

  2. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    Hi Alex,

    This is indeed a bug. Right now, what you're trying to do only works if you also tick the "Use custom HTML Markup" option. Will take a look into this and post back with a fix so you can test it out for me.

  3. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    As promised, here's the fix:

    Open wordpress-popular-posts.php using an editor such as Windows' Notepad or Adobe Dreamweaver, and replace this code (around line 726):

    // build custom layout
    if ($instance['markup']['custom_html']) {
        if ($instance['markup']['pattern']['active']) {
            $content .= htmlspecialchars_decode($instance['markup']['post-start'], ENT_QUOTES) . $this->format_content($instance['markup']['pattern']['form'], $data, $instance['rating']) . htmlspecialchars_decode($instance['markup']['post-end'], ENT_QUOTES) . "\n";
        } else {
            $content .= htmlspecialchars_decode($instance['markup']['post-start'], ENT_QUOTES) . $thumb . '<a href="'.get_permalink($wppost->ID).'" title="'. $title_attr .'"><span class="wpp-post-title">'. $tit .'</span></a>'.$post_content.' '. $stats . $rating . htmlspecialchars_decode($instance['markup']['post-end'], ENT_QUOTES) . "\n";
        }
    } else {
        $content .= '<li>'. $thumb .'<a href="'. get_permalink($wppost->ID) .'" title="'. $title_attr .'"><span class="wpp-post-title">'. $tit .'</span></a>'. $post_content .' '. $stats . $rating .'</li>' . "\n";
    }

    ... with this:

    // build custom layout
    $innerHTML = "";
    if ($instance['markup']['custom_html'] || $instance['markup']['pattern']['active']) {
    	if ($instance['markup']['pattern']['active']) {
    		$innerHTML = $this->format_content($instance['markup']['pattern']['form'], $data, $instance['rating']);
    	} else {
    		$innerHTML = $thumb . '<a href="'.get_permalink($wppost->ID).'" title="'. $title_attr .'"><span class="wpp-post-title">'. $tit .'</span></a>'.$post_content.' '. $stats . $rating;
    	}
    	$content .= htmlspecialchars_decode($instance['markup']['post-start'], ENT_QUOTES) . $innerHTML . htmlspecialchars_decode($instance['markup']['post-end'], ENT_QUOTES) . "\n";
    } else {
    	$content .= '<li>'. $thumb .'<a href="'. get_permalink($wppost->ID) .'" title="'. $title_attr .'"><span class="wpp-post-title">'. $tit .'</span></a>'. $post_content .' '. $stats . $rating .'</li>' . "\n";
    }

    Gotta add that the {image} and {summary} tags need to be activated by ticking their respective options ("display post excerpt" and "display post thumbnail") in order to work. Otherwise these tags will be ignored when building the HTML output.

    Anyways, give it a try and let me know the results.

  4. alexsteninge
    Member
    Posted 3 years ago #

    Hi Ikki,

    Thx for the very quick reply. I have tested both solutions and they both work. I will go with the check the Use custom HTML Markup because this does not entail custom coding which can be hard to track. As you wrote yourself, you merely need to check the box, i.e. not actually add any code.

    Thx again. What a great plugin!

  5. Héctor Cabrera
    Member
    Plugin Author

    Posted 3 years ago #

    That's good to know, Alex! Still, I'm probably adding this change into WordPress Popular Posts for the next release as chances are that someone else will run into this issue too.

    Thank you for your feedback!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic