Clearing cache fixes Featured Image/Post Title problem
-
I have this code in a child theme functions.php to do what the title says, as the Enfold theme default is to place the Featured Image above the Post Title and meta data. The function has been in use on the site successfully for years.
/* * Move Featured Image below Post Title */ function add_custom_script(){ if(is_singular('post')){ ?> <script> (function($){ $(window).load(function() { $('article.post').each(function(){ $(this).find('.entry-content-header').after($(this).find('.big-preview').detach()); }) }); })(jQuery); </script> <?php } } add_action('wp_footer', 'add_custom_script');This code function has recently stopped working, with the FI now showing above the post title.
Posts display these errors in Chrome Dev Tools Console:
jquery.min.js:2 Uncaught TypeError: e.indexOf is not a function at S.fn.init.S.fn.load (jquery.min.js:2) at (index):252 at (index):257 jquery.min.js:2 Uncaught TypeError: e.indexOf is not a function at S.fn.init.S.fn.load (jquery.min.js:2) at i ((index):260) at (index):267 at (index):268 (index):271 Uncaught ReferenceError: wp is not defined at (index):271 (index):274 Uncaught ReferenceError: wp is not defined at (index):274 at (index):275 autoptimize_d99ee2cbe3587481a6d370bc4e66f03f.js:5 JQMIGRATE: Migrate is installed, version 3.3.2If I clear the Autoptimize cache and hard refresh a post, the PHP code ‘does its job’ and the Post Title appears above the FI, and the Console errors disappear.
If I then load posts for the next hour or so, the Title appears above the FI. When I visit the site the next day and load a post, the problem has re-appeared and Title and FI are swapped back to theme default. Clear the cache again, and all is OK.
This would indicate (perhaps…) that the problem is related to Autoptimize. Any ideas?
These are my…
JavaScript Options
Optimise JavaScript Code? Yes
Aggregate JS files? Yes
Do not aggregate but defer? No
Also aggregate inline JS? No
Force JavaScript in <head>? No
Exclude scripts from Autoptimize: seal.js, js/jquery/jquery.js, js/jquery/jquery.min.js
Add try-catch wrapping? NoThe page I need help with: [log in to see the link]
The topic ‘Clearing cache fixes Featured Image/Post Title problem’ is closed to new replies.