Function to Fix Paragraph Spacing for Facebook
-
We publish entire articles to Facebook: Post Title, Post Content, and Image. I noticed that the content on Facebook treats paragraphs like line breaks, rather than having spacing between paragraphs. I know the fix is to have \n\n inserted after every paragraph, but I need help in the function to override the plugin defaults. I wrote the following, but it isn’t working. Am I using the wrong hook?
function rop_change_share_content( $content, $post_id ){ //remove empty paragraphs $content = str_replace('<p> </p>', '', $content); $content = str_replace('<p></p>', '', $content); //add spacing for facebook $content = str_replace('</p>', "</p>\n\n", $content); return $content; } add_filter('rop_content', 'rop_change_share_content', 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Function to Fix Paragraph Spacing for Facebook’ is closed to new replies.