0

我在 WordWress 模板中使用来自 w3school 的 jQuery 手风琴,同时获得一个帖子格式,手风琴只能在奇数位置工作,唯一有效的手风琴是第 1、第 3、第 5 等等。
这是手风琴的脚本:

<script>
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var panel = this.nextElementSibling;
    if (panel.style.maxHeight) {
      panel.style.maxHeight = null;
    } else {
      panel.style.maxHeight = panel.scrollHeight + "px";
    } 
  });
}
</script>

这是模板的代码

<?php $display = roogan_get_episode_layout_options('e'); ?>

<article <?php post_class('roogan-item roogan-post section-item-vertical-rhythm roogan-layout-e roogan-is-podcast'); ?>>
    <div class="row justify-content-center">

        <div class="col-12 col-md-6 col-lg-6"> 
            <?php if ( $fimg = roogan_get_featured_image( 'roogan-e' ) ): ?>
                <div class="entry-media entry-media-br-6">
                    <a href="<?php the_permalink(); ?>"><?php echo roogan_wp_kses( $fimg ); ?></a>
                    <?php if ( $display['play_icon'] ) : ?>
            <?php roogan_play_button( 'roogan-button-play roogan-button-play-white roogan-button-play-large', false ); ?>
                    <?php endif; ?>
                </div>
            <?php endif; ?>
        </div>

        <div class="col-12 col-md-6 col-lg-6">            
        
            <div class="entry-header">
                
                <?php if( $display['category'] ): ?>
                    <div class="entry-category mb--sm"><?php echo roogan_get_category(); ?></div>
                <?php endif; ?>
                
                <h2 class="entry-title h1"><a href="<?php the_permalink(); ?>"><?php echo roogan_get_episode_title(); ?></a></h2>

                <?php if( $display['meta'] ): ?>
                    <div class="entry-meta mt--md">
                        <?php echo roogan_get_meta_data( $display['meta'] ); ?>
                    </div>
                <?php endif; ?>   

            </div>

            <?php if( $display['excerpt'] ): ?>
                <div class="entry-content mt--lg">
                    <?php echo roogan_get_excerpt( $display['excerpt'] ); ?>
                </div>
            <?php endif; ?>

        </div>
        
  </div>
</article>
4

0 回答 0