We are currently using Ajax infinite scroll for blog posts. But we wanted to included scripts (javascript) on every blogposts. Everything works fine except the script only show once at the very top portion of the blogpost.
here is the snippet for the singles.php loop which has been modified for Ajax infinite scroll standards:
<?php while ( have_posts() ) : the_post(); ?>
<?php if (et_get_option('divi_integration_single_top') <> '' && et_get_option('divi_integrate_singletop_enable') == 'on') echo(et_get_option('divi_integration_single_top')); ?>
<?php
echo do_shortcode('[ajax_load_more cache="true" cache_id="2869844236" cta="true" cta_position="after:1" css_classes="call-to-actions call-to-actions-js" images_loaded="true" post_type="post" repeater="default" previous_post="true" previous_post_id="'. get_the_ID() .'" posts_per_page="1" button_label="Previous Post"]');
?>
<?php endwhile; ?>
and here is the snippet for the repeater template which include a simple script code.
<article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>
<script>
document.write("This text is displayed using a simple javascript.");
</script>
<div class="et_post_meta_wrapper">
<h1><?php the_title(); ?></h1>
<?php the_post_thumbnail('hero', array('alt' => get_the_title())); ?>
</div>
<div class="entry-content">
<?php
do_action( 'et_before_content' );
the_content();
wp_link_pages( array( 'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'Divi' ), 'after' => '</div>' ) );
?>
</div>
</article>
Not sure why the script only show once. when I've placed it on the top of the title of each blogposts.