theme development - [&hellip appearing instead of [...]

admin2025-06-03  5

There is some problem with my wordpress website, instead of [...] I am getting [&hellip everywhere. I have changed the charset to UTF-8 but the problem persists. Any help would be appreciated.

Here is the link to the website : /

There is some problem with my wordpress website, instead of [...] I am getting [&hellip everywhere. I have changed the charset to UTF-8 but the problem persists. Any help would be appreciated.

Here is the link to the website : http://theappjuice/

Share Improve this question edited Feb 8, 2019 at 23:59 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Aug 7, 2013 at 19:54 RookieRookie 1231 gold badge1 silver badge8 bronze badges 2
  • Try disabling your plugins. If the issue goes away, re-enable them one by one till it reappears. That'll be your problem. (Also: … is the HTML entity for '…'. Something might be trimming off the semicolon character.) – Pat J Commented Aug 7, 2013 at 20:04
  • 1 Just peeked at your site -- what does your code look like for The Loop? (You're looking for something in the PHP files that starts with while( have_posts() ) : and ends with endwhile;, most likely.) If you can paste that into your question, that may help people diagnose the issue. – Pat J Commented Aug 7, 2013 at 20:51
Add a comment  | 

3 Answers 3

Reset to default 2

I was super-frustrated by this issue (and disappointed the OP didn't let us in on how he fixed it, since I can see on his site that he did... Maybe he just changed themes?).

FWIW, the ellipses were at one time displaying correctly. But, some upgrade must have broken it.

My excerpts were displayed like this:

    the equipment involved [&hellip

and the source rendered like this:

    the equipment involved [&#038;hellip</p>

while I was expecting them to be displayed like this:

    the equipment involved ...

I tweaked and played with formatting.php and default-filters.php to no avail.

Finally, I figured it had to be theme-related. Maybe, maybe not, but that is where I was able to ultimately fix it.

I found this function in my theme's functions.php:

    // Remove [...]
    function trim_excerpt($text) {
     return rtrim($text,'[...]');
    }

I updated it to:

    // Remove [...]
    function trim_excerpt($text) {
     return $text;
    }

I didn't really want the brackets around the ellipsis, so my final version looks like this:

    // Remove [...]
    function trim_excerpt($text) {
     $text = str_replace('[', '', $text);
     $text = str_replace(']', '', $text);
     return $text;
    }

My excerpts now correctly display the ellipsis, at least how I wanted to display them.

I hope this helps anyone running into this problem.

Did almost the same, this was the answer for me:

// Replace the default ellipsis
function trim_excerpt($text) {
     $text = str_replace('[&hellip;]', '', $text);
     return $text;
    }
add_filter('get_the_excerpt', 'trim_excerpt');

To clarify why it happened, it's because rtrim( $text, '[...]' ) notation used to remove the default ellipsis in some themes is incorrect.

Per trim() function description, the second argument is treated as a list of characters, not as a string. Moreover, [... is treated as a range of ASCII characters from full stop (code 2E) to opening square bracket (code 5B). So, instead of the [...] substring, the code in question removes any character falling within that range (including semicolon, code 3B), as well as closing square bracket.

In WordPress 3.6, [...] was changed to [&hellip;] for better typography.

That's not an issue per se, however rtrim( $text, '[...]' ) cuts off the last two characters of that string, leaving just [&hellip.

The solution is to use str_replace( '[&hellip;]', '', $text ) for WordPress 3.6+, or str_replace( '[...]', '', $text ) for earlier versions. You can also combine both replacements if you'd like: str_replace( array( '[&hellip;]', '[...]' ), '', $text ).

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748928437a314897.html

最新回复(0)