Custom Facebook message using the_excerpt filter
-
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_excerptfilter 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_excertpfilter 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_excerptfilter 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)
Viewing 1 replies (of 1 total)
You must be logged in to reply to this topic.