WordPress.org

Support

Support » Plugins and Hacks » [Plugin: WP-PostRatings] HTML tags in post_excerpt

[Plugin: WP-PostRatings] HTML tags in post_excerpt

  • nickscipio

    @nickscipio

    Lester,

    I have a problem with the latest WP_PostRatings. My post excerpts are HTML <img> tags (custom theme from before the days of favorite image). The HTML in the excerpt screws up the meta tags for the Google Rich Snippet.

    I fixed the problem by adding strip_tags() to the ratings_post_excerpt function in wp-postratings.php.

    If you don’t mind, please check out the modified code and add it to the next release. Thanks in advance. – Nick

    Modified ratings_post_excerpt:

    ### Function: Process Post Excerpt, For Some Reasons, The Default get_post_excerpt() Does Not Work As Expected
    function ratings_post_excerpt($post_id, $post_excerpt, $post_content) {
    	if(post_password_required($post_id)) {
    		return __('There is no excerpt because this is a protected post.', 'wp-postratings');
    	}
    	if(empty($post_excerpt)) {
    		return snippet_text(strip_tags($post_content), 200);
    	} else {
    		return strip_tags($post_excerpt);
    	}
    }

    http://wordpress.org/extend/plugins/wp-postratings/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Great, it works! Thank you very much 🙂

    Hello nickscipio,

    I have had the same problem. Thank you for your solution. It would be very nice, if that piece of code could be added to the next plugin version.

    Kristian

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WP-PostRatings] HTML tags in post_excerpt’ is closed to new replies.