Forums

[resolved] get_the_excerpt returns no string (7 posts)

  1. m1546
    Member
    Posted 6 months ago #

    Hello,
    the_excerpt() functions retrieves first 55 words if there is no entry in excerpt field and that is OK.
    But, get_the_excerpt() function does not get first 55 words of content if there is no entry in excerpt field, but returns empty string.
    How is it possible to get first 55 words of contenet in case there is no entry in excerpt field?
    Thank you.

  2. keesiemeijer
    moderator
    Posted 6 months ago #

    Try it with one of these functions in your theme's functions.pgp:
    http://wordpress.org/support/topic/two-different-excerpt-lengths?replies=5

  3. m1546
    Member
    Posted 6 months ago #

    Thank you. It has helped.

    There is only a small issue when using get_my_excerpt, namely retrieved string contains html codes for special characters (f.e. &#8220 for ").

  4. keesiemeijer
    moderator
    Posted 6 months ago #

    Try calling the function like this:

    $excerpt = html_entity_decode(get_my_excerpt(), ENT_QUOTES, 'UTF-8');
    echo $excerpt;
  5. m1546
    Member
    Posted 6 months ago #

    It's good now, thank you.

  6. keesiemeijer
    moderator
    Posted 6 months ago #

    You're welcome. Glad you got it resolved.

  7. m1546
    Member
    Posted 6 months ago #

    p.s. It would be helpful that Wp function get_the_excerpt() could retrieve first n(55) words of content, if there is no entry in the excerpt field, like the_excerpt() function does so.

Reply

You must log in to post.

About this Topic