• Hello, folks.

    I’m trying to achieve a custom message to be used at the publication of the post on the Facebook page.

    I’m trying to use the_excerpt filter to get the first paragraph of the text, trought the following function:

    function xyz_facebook_excerpt_format($excerpt)
    {
    $content = get_the_content();
    $content = apply_filters('the_content', $content);
    $end_of_paragraph = strpos($content, '</p>');
    $excerpt = $end_of_paragraph ? substr($content, 0, $end_of_paragraph + 4) : $content;
    return $excerpt;
    }
    add_filter('the_excerpt', 'xyz_facebook_excerpt_format', 5);

    The option to apply the_excertp filter is enabled at the plugin settings page, but the grabed paragraph is not being used as desired. Sometimes it was replaced by the standard first 50 charactes of the text.

    I’m using the_excerpt filter with the priority 5, to trying to ensure that it be triggered in time.

    Any help would be appreciated.

Viewing 1 replies (of 1 total)
  • Hi,
    The plugin currently applies the the_excerpt filter only to the manual excerpt field (post_excerpt). When no manual excerpt is set, the plugin generates its own fallback excerpt from the first 50 words of the content, and the filter may not be applied to that generated excerpt. This is why you may sometimes see the default 50-word excerpt instead of the value returned by your custom filter. We will review this behavior and consider applying the filter to generated excerpts as well for consistency.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.