I'm trying to insert a block of mixed html/php code into a Wordpress post. It is filled by custom field values from ACF Pro. It's supposed to be part of the post, so I try to avoid editing template files.
The block looks contains roughly the following:
<?php if (get_field('infobox_anzeigen') == 1): ?>
<div class="touristische-informationen">
<h2>Informationen</h2>
<!-- Start Allgemein -->
<?php if( have_rows('ti_allg')): ?>
<h3>Übersicht</h3>
<div class="ti-div">
<?php if (have_rows('ti_allg_bezeichnung')): ?>
<p><b>Name: <?php the_field('ti_allg_bezeichnung_name') ?> (<?php the_field('ti_allg_typ'); ?>)</b></p>
<?php if (get_field('ti_allg_bezeichnung_kanji')): ?>
<p>Kanji: <?php the_field('ti_allg_bezeichnung_kanji'); ?> | <?php the_field('ti_allg_bezeichnung_kana'); ?> | <i><?php the_field('ti_allg_bezeichnung_hepburn'); ?></i></p>
<?php endif; ?>
<?php endif; ?>
<?php if (get_field('ti_allg_besucht')): ?>
<p>Besucht am: <?php the_field('ti_allg_besucht'); ?></p>
<?php endif; ?>
...imagine the end of this code.
What's certainly working are those "insert php snippets" plugins, which I'd like to avoid for now. I tried making a custom shortcode via custom plugin, but because of the mixed code nature, I ran into issues with echo and output buffering etc. Although that would be probably the best solution for my use case as this would allow me to still add text before and after the block.
How would you tackle this problem? Using a insert php plugin? Following the custom shortcode approach? Something entirely else?