我想在wordPress中为特定的自定义帖子类型添加更多加载按钮。单击按钮后显示

问题描述 投票:0回答:1

这是PHP和文件的代码保存为aboutus.php。现在请告诉我,我想在WordPress中为特定的自定义帖子类型添加更多加载按钮。单击按钮后显示

  <div class="container">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
      <h2>News & Announcements</h2>
    </div>

     <?php 
            $args = array('post_type' => 'news','showposts'=>6, 'order'=>'ASC');
            $query = new wp_query ($args);
            while( $query->have_posts() ): $query->the_post() ;
            $img = wp_get_attachment_url(get_post_thumbnail_id($result->ID));
          ?>

    <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 news">

      <figure><img src="<?php echo $img; ?>"></figure>

      <h3><?php the_title(); ?></h3>

      <?php the_content(); ?>

    </div>

    <?php endwhile; ?>

   </div>

   <div class="container">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
      <h4>
        <a id="toggle">Show more</a>
     </h4>
    </div>
   </div>
</div>
wordpress advanced-custom-fields
1个回答
0
投票

您将不得不使用javascript添加事件监听器以收听#toggle按钮上的“click”事件,发出ajax请求以获取下一个帖子并在成功时将帖子附加到帖子中。

这帮助我开始制作ajax请求:https://premium.wpmudev.org/blog/using-ajax-with-wordpress/

© www.soinside.com 2019 - 2024. All rights reserved.