subscribe: Posts | Comments | Email | Twitter     external: Forum | Issue Tracker

The Excerpt problems

2 comments
The Excerpt problems

One of the most common problems with integrating rating system in blogs was the problem caused by the excerpts. In fact, the problem is caused by the wrong use of the excerpt feature. Excerpt should be short overview of the post, or summary of the post long 2-3 sentences. But there are many blogs where post authors write only main post content and not the excerpt.

The Problem

On the other hand, many WordPress themes use excerpt for posts on front page or in archive. And that is all fine if you actually have excerpts written for each post. If you don’t, and the excerpt is called, and GD Star Rating is set to auto insert rating code, then you will end up with something like this:

Excerpt problem in action

Excerpt problem in action

As you can see, rating block is not there. Instead you have only text parts of the block plus small debug info. And here is the reason why this happens. When the theme calls get_the_excerpt() function, WordPress first tries to get the excerpt saved with the post. If the excerpt is not found, WordPress calls the_content() function, and gets the full post content, than it shortens it and return it as an excerpt. GD Star Rating plugin is added to the the_content() call, and in the process is returned as the part of the excerpt.  Also, excerpt is striped from all HTML elements and you get only parts of the rating block as on the picture above.

The Solution(s)

So, how to solve this? This depends on what you want to achieve.

If you want to display rating block with the post that is shown as excerpt, you must use manual insertion method and add php call for rendering of the rating block into the theme after the excerpt call, and within the post loop. Function is: wp_gdsr_render_article(). Also, you need to prevent problem described above. To do this, best solution is to write actual excerpts with the posts. If you don’t want to do this, than you need to disable auto insertion of the rating block. You can disable it only for the archive or the front page where usually excerpts are used. Options for this are located on plugin Settings panel, Posts and Pages tab as Auto insert rating code.

If you don’t want rating block displayed on pages with excerpts, you need to do the same as the above, but skip adding call to the render function.

My suggestion is to have actual excerpts for each post. But if you have a blog with over a 1000 posts without the excerpt, it’s not easy to do that. In that case is better to turn off auto inserting of rating code, and if you want add render call into the theme.

This is all on this topic, please don’t send any more questions about this problem, this post contains everything you need to solve it. Also, check out the user guide if you need more info on rendering functions or plugin settings.

GD Star Rating
loading...
The Excerpt problems7.41074


  1. I would like to know how to change the displayed rating as stars ONLY without the number of votes underneath… also I would like people to only be able to vote from the article page itself and any display of the rating through the Excerpt to be just the stars of the current voted rating.

    GD Star Rating
    loading...