Docs    Facebook    Troubleshooting

The formatting of my Facebook feed is incorrect or messed up

Broken feed formatting usually means the plugin CSS is not loading. How to check the page source and what else causes it.

Would you like to fix a Facebook feed that looks wrong, with broken spacing, missing styling or a layout that doesn’t match your settings?

Feed formatting problems usually come from one of three places. The plugin’s stylesheet may not be loading on your page, your theme or another plugin may be changing how the feed looks, or your theme may be reformatting the feed’s content. To find the cause, check them in order until your feed looks right.

Here is what we will cover.

The Plugin’s CSS File Is Not Loading

To get started, we’ll check whether your page loads the plugin’s CSS file.

Facebook Feed styles your feed with a CSS file. If your page doesn’t load that file, the feed shows without its styling. To check, view the page source of a page that shows the feed.

  1. Open the page that shows your feed in your browser.
  2. Right-click anywhere on the page and choose View Page Source.
  3. Search the source for cff-style. The plugin adds the file to the head of your page with a link tag like the example below.

Here is an example of the link tag in the paid version. In the free version, the folder name is custom-facebook-feed.

<link rel='stylesheet' id='cff-css' href='https://example.com/wp-content/plugins/custom-facebook-feed-pro/assets/css/cff-style.min.css?ver=VERSION' type='text/css' media='all' />

If the file isn’t there, it’s most likely that your theme doesn’t call the WordPress wp_head() function in its header.php file. Plugins use this function to add their CSS files to your page. To add it, open your theme’s header.php file and add the following line before the closing </head> tag.

<?php wp_head(); ?>

The plugin’s JavaScript file loads in the footer of your page. Your theme also needs the wp_footer() function in its footer.php file.

The plugin loads its CSS and JavaScript files on every page of your site. This keeps them ready on any page where you add a feed.

If the file loads and your feed still looks wrong, move on to the next section.

Your Theme or Another Plugin Is Changing the Feed’s CSS

The plugin is designed to inherit the CSS from your theme. That way, your feed matches the look of your site. Sometimes a rule from your theme’s stylesheet, or from another plugin, changes how the feed looks. This can cause small formatting problems.

Every feed sits inside an element with the ID cff. When you write your own CSS rules, start them with #cff. That way, they change only the feed and leave the rest of your site alone. To learn how to add them, see our guide on using custom CSS code in our plugins. If you can’t find the cause of the problem, please contact our support team for help.

If your feed still looks wrong, the last place to check is how your theme formats content.

Your Theme Is Reformatting the Feed’s Content

Some themes use their own content formatting function in place of the WordPress default. This can cause formatting problems in the feed, such as empty paragraphs.

Some themes include a [raw] shortcode. It comes from the theme, not from Facebook Feed. If your theme has it, try wrapping the feed shortcode like this.

[raw][custom-facebook-feed][/raw]

If that doesn’t solve the problem, add the following code to the functions.php file of a child theme. You can also add it with a code snippets plugin. Then wrap the feed shortcode in [raw] tags as shown above. The code turns off the automatic paragraphs WordPress adds to your content. Then it adds them back everywhere except inside [raw] tags.

function cff_formatter($content) {
    $new_content = '';
    $pattern_full = '{(\[raw\].*?\[/raw\])}is';
    $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
    $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

    foreach ($pieces as $piece) {
        if (preg_match($pattern_contents, $piece, $matches)) {
            $new_content .= $matches[1];
        } else {
            $new_content .= wptexturize(wpautop($piece));
        }
    }
    return $new_content;
}
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('widget_text', 'do_shortcode');
add_filter('widget_text', 'cff_formatter', 99);
add_filter('the_content', 'cff_formatter', 99);

If you still see empty paragraphs in your feed, add the following JavaScript to your site. It removes the empty paragraphs inside the feed. To learn how to add it, see our guide on adding custom JavaScript code to your site.

jQuery(function($){
  $('#cff p').each(function(){
    if($(this).html().length < 2) $(this).remove();
  });
});

That’s it! You can now check that the plugin’s CSS file loads, spot CSS conflicts from your theme or other plugins, and try the workarounds for a theme that reformats your feed. To learn more about the options you can add to a feed, see our shortcode reference.

Frequently Asked Questions

Below, we’ve answered some common questions about feed formatting.

How do I know which file my feed uses for its styling?

The plugin’s stylesheet is named cff-style.min.css. Its link tag has the ID cff-css. To find either one in your page source, follow the steps in The Plugin’s CSS File Is Not Loading.

Does Facebook Feed add the [raw] shortcode to my site?

No. The [raw] shortcode comes from some themes. If your theme doesn’t include it, WordPress leaves the [raw] tags in your content, so they show as plain text on your page. In that case, skip the first wrapping step and add the code snippet in Your Theme Is Reformatting the Feed’s Content.

Do I need the paid version to use these fixes?

No. The free and paid versions both load a CSS file named cff-style.min.css and wrap the feed in an element with the ID cff. This means these steps apply to both.

support

Couldn’t find your answer in the docs?

Contact Support