mercredi 6 avril 2016

Ajax Load More and conditional loop

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 ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire