PHP snippet shortcode only works once
-
Hello,
just wondering why my little php snippet only works once.
Added this small script inside a Gutenberg post loop area to add an ACF variable to css.<?php while (have_posts()) : the_post(); ?> <style type="text/css"> li.post-<?php echo esc_attr( get_the_ID() ); ?> { some css here } </style> <?php endwhile; ?>Adding the script as a shortcode inside the post loop element works fine on archive template with twenty twenty four.
But if i try to add the script shortcode inside another post loop element on a page, it doesn’t show up and no <style> is added. Seems it code only works once…
I’ve already tried to use it as a universal snippet with an ending ‘?>’
No condition logics.Can you help? Many thanks in advance!
Best, Sven
The topic ‘PHP snippet shortcode only works once’ is closed to new replies.