Formatting get_post content doesn’t allow JS content to function properly

I am currently pulling in the latest post on a category page based on which category you click on. When you click on the category “Code Examples” you see this:

enter image description here

Read More

I am using the Crayon syntax highlighter plugin, which works fine, but when I use the following code to pull in the above content, it doesn’t look the same as it does on the actual post page (below):

enter image description here

$post_content = get_post($post->ID);
    // format the raw data
    $content = sanitize_post_field('post_content', $post_content->post_content, $post->ID, 'display');
?>
    <div id="docs-category-page">
        <article id="docs-post">
        <h1 class="entry-title"><?php echo get_the_title($post->ID); ?></h1>
            <?php echo $content; ?>
        </article>

I have looked up apply filters, etc, but since Crayon plugin uses JS for its functionality, the data from get posts doesn’t look the same… Need a remedy and fast! Thanks!

Related posts

Leave a Reply