Ready to get started?Download WordPress


HTML tags in post_excerpt (3 posts)

  1. nickscipio
    Posted 1 year ago #


    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);


  2. Laram
    Posted 1 year ago #

    Great, it works! Thank you very much :)

  3. Kristian
    Posted 1 year ago #

    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.


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic