code-syntax-block
code-syntax-block copied to clipboard
Styles not applied to dynamically added posts
Posts that are added to a post feed via an AJAX call do not seem to have styles applied from the Code Syntax Block plugin. Is there a way to automatically catch newly added content or a way that restyling could be triggered on elements after such content has been added? You can see this issue here when you load more posts.
I was able to hook into an event after having added posts and called Prism.highlightAll();
which fixed this for me.
Hey @uamv, I've just ran into the same issue. No styles being added to post which is loaded via the Worpress 'Recent Posts' widget.
Could you share some details on how you got this working?
I was encountering this while using GeneratePress theme and its infinite scroll feature for archive pages. I was able to use the following code to trigger Prism.highlightAll()
when append.infiniteScroll
ran.
jQuery(document).ready(function($) {
var $container = $( '#main article' ).first().parent();
$container.on( 'append.infiniteScroll', function( event, response, path, items ) {
Prism.highlightAll();
} );
});
I've tried getting it to trigger like you have but not having any luck. But, I noticed in the readme you can force it to load by adding this to functions.php
add_filter('mkaz_code_syntax_force_loading', '__return_true');
Worked a treat