WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Numeric entities displaying on home page/excerpts (11 posts)

  1. weazel
    Member
    Posted 2 years ago #

    Hi everyone!

    I can't fathom this one out... If you look at the excerpts on the home page (http://www.beatculture.net), you will see that the theme is displaying numeric entities instead of en-dash, ampersands etc.

    Here is an example: the text looks like this in the full post:

    Tech:nology – one of London’s leading promoters of dark, underground Drum & Bass – once again takes over the world famous Scala in King’s Cross.

    But the theme displays the excerpt text on the home page like this instead:

    Tech:nology one of London’s leading promoters of dark, underground Drum & Bass once again takes over the world famous Scala...

    It is just the excerpts that have this problem. I'm not responsible for the uploading of the new content, but I've been assured that it's being written directly in WordPress and no copied-and-pasted from Microsoft Word or anything.

    How can I fix this? Is it something I need to change in the code or is there a plug-in that will fix this throughout all the existing content?

    All ideas much appreciated...

    Thanks in advance,
    Chris

  2. weazel
    Member
    Posted 2 years ago #

    Sorry – double post - and the entities aren't displaying here. Please see the post excerpts on the homepage to see what I mean: http://www.beatculture.net

    Thanks

  3. Phil
    Member
    Posted 2 years ago #

    Weird one this, it's like it's not converting html symbols into text-alternatives. Some of the codes like '–' should be converted to a '-' on the site, but they're not.

    I'm stumped on this one, but you could maybe hunt through the code to find where they are coming from and try manually adding in their html equivalent in your template files.

  4. weazel
    Member
    Posted 2 years ago #

    Yeah – I can't understand why the full posts are displaying them properly, but the excerpts are not. I have no idea where this is being set either.

    If I don't get this fixed by Wednesday evening, I'm in trouble!

  5. esmi
    Forum Moderator
    Posted 2 years ago #

    Does your theme's index.php template file use <?php the_excerpt();?>?

  6. weazel
    Member
    Posted 2 years ago #

    It doesn't feature that exact line, but does feature:

    $excerpt = get_the_excerpt();

    and

    <p><?php echo limit(150, $excerpt); ?></p>

    Both of those are within this chunk of code:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  7. chadrew
    Member
    Posted 2 years ago #

    This might be a dumb question... Is "limit" a custom function in your theme's functions.php file?

  8. weazel
    Member
    Posted 2 years ago #

    Hmmm... I just found this in functions.php:

    // LImit caracters
    function limit($nb,$var) {
        $max= $nb;
         if(strlen($var)>=$max)
         {
           $var    = substr($var,0,$max);
           $espace = strrpos($var," ");
           $var    = substr($var,0,$espace)."...";
    	   $var    = htmlspecialchars($var);
         }
        return $var ;
    }

    Any use?

    (thank you for everyone's help so far - I'm very grateful)

  9. chadrew
    Member
    Posted 2 years ago #

    Try removing the $var = htmlspecialchars($var); line.

  10. weazel
    Member
    Posted 2 years ago #

    Brilliant - thank you! Removing that line seems to have fixed things.

    Thanks everyone for trying to help as well.

  11. chadrew
    Member
    Posted 2 years ago #

    Great. I realized afterwards that limit() might be used in other places on your theme, which need special chars converted (like meta description or whatever). I suppose a safer way would be leaving limit() intact, and creating an identical function without the offending line (call it limit2 or whatever).

    Then instead of <p><?php echo limit(150, $excerpt); ?></p> you would use <p><?php echo limit2(150, $excerpt); ?></p>, while other areas of your theme will still use the original with its special char conversion.

Topic Closed

This topic has been closed to new replies.

About this Topic