【发布时间】:2018-04-02 10:57:06
【问题描述】:
我们目前正在为博客文章使用 Ajax 无限滚动。但我们希望在每篇博文中都包含脚本(javascript)。一切正常,除了脚本只在博文的最顶部显示一次。
这里是 singles.php 循环的 sn-p,它已针对 Ajax 无限滚动标准进行了修改:
<?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; ?>
这里是转发器模板的 sn-p,其中包含一个简单的脚本代码。
<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>
不知道为什么脚本只显示一次。当我把它放在每篇博文的标题顶部时。
【问题讨论】:
标签: wordpress wordpress-theming infinite-scroll