Support » Plugin: Autoptimize » Autoptimize is blocking Facebook Open Graph

  • Resolved alejandrofm

    (@alejandrofm)


    Hello team,

    I am using autoptimize (last version) with my template Jupiter (last version) and when the plugin is activated it is blocking the info to show up in Facebook Open Graph.

    After taking a look around the forum I didn’t find anything about it. Also not in other forums. It would be the only thing I need for everything to work properly.

    Can you help me?

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    Evening Alejandro;
    This is probably due to the fact that AO by default injects the autoptimized CSS before the title. You can change that with a couple of lines of code that hooks into AO’s API, for example;

    add_filter('autoptimize_filter_css_replacetag','biogesund_css_replacetag',10,1);
    function biogesund_css_replacetag($replacetag) {
    	return array("</head>","before");
    	}

    hope this helps,
    frank

    Thank you! I had the same problem and that code worked perfectly.

    Could you tell me where this code has to be placed?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    easiest/ safest way is using the code snippets plugin @ansuman84

    Hi,

    Thanks for the fix. It worked perfectly but it conflicts with the way the site loads. I am using the Divi theme and pasted this code into the functions.php file. Once I cleared the cache I noticed the template didn’t load properly. If i remove the code from the fuctions.php file and clear cache everything works fine again. Is there another way to resolve the issue with Autoptimize blocking Facebook Open Graph?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Is there another way to resolve the issue with Autoptimize blocking Facebook Open Graph?

    well, assuming you’ve got the “inline all CSS”-option on which is typically the reason for the opengraph tags not to be “seen” by FB; don’t inline all CSS? 😉

    Thanks for your response. I ended up doing this to solve the issue. I was just wondering whether there was another way to keep the inline all CSS enabled. In saying that there isn’t much difference in website speed and/or score having this turn off so I will just keep this option off 🙂

    Spent 2 days asking my hosting service provider, my IT friends and hours of reading forums on solving a problem with my articles.

    I can’t have my links show up on facebook when shared.

    Until, I decided to UNCHECK all aggregate js and css options in the settings of this plugin. I decided to view the source code of my site when aggregate options were turned on and it is so different when I turn it off.

    Now, my article sharing on facebook has been solved!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I decided to UNCHECK all aggregate js and css options in the settings of this plugin

    The JS options won’t matter, as the JS is added at the very end of the HTML. CSS settings do matter, esp. “inline all CSS” can result in FB not “seeing” the opengraph tags (even thought they remain available in the page). As explained higher up you can tell AO to inject the CSS elsewhere (later).

    Wzn

    (@fjellsiktno)

    Works perfectly! 😀

    Maybe add this to next update so people doesnt need to adda new plugin and add the code? 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Autoptimize is blocking Facebook Open Graph’ is closed to new replies.