dtntjwkl83750 2016-04-06 07:53
浏览 45

Ajax加载更多和条件循环

I am trying to set up a wordpress. For my blog page, I displayed items differently depending on the position of the article (first line) and content (quote or article with image). It does the job.

    <?php $post_counter = 0; // START COUNTDOWN ?>
<?php if ( have_posts() ) : ?>
  <?php query_posts('category_name=blog'); ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php $post_counter++; // COUNTDOWN FOR EACH POST ?>


    <!-- IF FIRST POST -->

        <?php if ( $post_counter == 1 ) : ?>
          <div class="first">
          <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
          <div style="background-image:url('<?php echo $url; ?>')" class="fullimg">
          </div>
              <a href="<?php the_permalink() ?>">
                <?php the_title() ?>
                <?php echo get_the_date( 'd/m/Y' ); ?>
              </a>
          </div>
        <?php endif; ?>

        <!-- IF NOT FIRST POST -->

        <?php if ( $post_counter != 1 ) : ?>

          <!-- IF NOT FIRST POST AND IS A QUOTE -->
          <?php if ( has_post_format( 'quote' )) : ?>
            <div class="quote">
              <?php the_content() ?>
              <?php echo get_the_date( 'd/m/Y' ); ?>
            </div>
          <?php endif; ?>

          <!-- IF NOT FIRST POST AND IS NOT A QUOTE -->
          <?php if ( !has_post_format( 'quote' )) : ?>
            <div class="noquote">
            <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
            <div style="background-image:url('<?php echo $url; ?>')" class="fullimg">
            </div>
                <a href="<?php the_permalink() ?>">
                  <?php the_title() ?>
                  <?php echo get_the_date( 'd/m/Y' ); ?>
                </a>
            </div>
          <?php endif; ?>

        <?php endif; ?>
    <?php endwhile; ?>
<?php endif; ?>

But now I want to integrate a load more, why I use the plugin "ajax load more". When I insert my hook into the template and the plugin integrates the shortcode, the button appears but nothing happens. Ideas ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
    • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
    • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序