I’m trying to build an index (cheat sheet) for basic HTML coding and I’m using the Crayon Syntax Highlighter plugin to display the code. I am using a repeater field with one WYSIWYG textarea that includes the code that I want to display. I’ve followed this tip on how to style the code with Crayon but it doesn’t seem to work (https://github.com/aramk/crayon-syntax-highlighter/issues/67) Any tips?
This is my current code:
<div class="entry-content" itemprop="text">
<?php if( have_rows('cheat') ): ?>
<div class="row">
<?php while ( have_rows('cheat') ) : the_row(); ?>
<div class="col-md-4">
<h2><?php the_sub_field('titel') ?></h2>
<?php the_sub_field('uitleg') ?>
<?php echo CrayonWP::highlight(the_sub_field('code')); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
The line should use get_sub_field() instead of the_sub_field()
<?php echo CrayonWP::highlight(get_sub_field('code')); ?>