繁体   English   中英

使用Ajax在Wordpress中加载更多帖子

[英]load more posts in Wordpress with Ajax

这是我的帖子循环:

<?php query_posts($query_string . '&showposts=8'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

        <div class="large-4 columns">
        <section class="post-home">
          <section class="the_category">
          <?php
            $categories = get_the_category();
            $separator = ' ';
            $output = '';
            if($categories){
                    foreach($categories as $category) {
                       $output .= '<span class="'.$category->cat_name.'"><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "Veja todos os posts em %s" ), $category->name ) ) . '">'.$category->cat_name.'</a></span>'.$separator;
                    }
            echo trim($output, $separator);
            }
?>
          </section>

          <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?> | <?php bloginfo('name') ?> | <?php bloginfo('description') ?>"><figure class="thumb-post" style="background: url('<?php echo $url; ?>') center center no-repeat;" ></figure></a>

          <section class="post-home-content">
            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?> | <?php bloginfo('name') ?> | <?php bloginfo('description') ?>"><?php the_title(); ?></a></h2>
            <p><?php the_field('sub_titulo'); ?></p>

            <span class="link">Compartilhe</span>

            <time class="post-time" datetime="<?php the_time('d-m-Y'); ?> <?php the_time('G:i'); ?>"><?php the_time('d/m/Y'); ?></time>
          </section>

          <ul class="social">
            <li><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=<?php the_permalink() ?>" title="Compartilhar <?php the_title(); ?> no LinkedIn" target="_blank"><img src="<?php bloginfo('template_url'); ?>/img/in.png" alt="" width="24" /></a></li>
            <li><a href="https://plus.google.com/share?url=<?php the_permalink() ?>" title="Compartilhar <?php the_title(); ?> no Google Plus" target="_blank"><img src="<?php bloginfo('template_url'); ?>/img/gp.png" alt="" width="24" /></a></li>
            <li><a href="http://www.facebook.com/sharer.php?u=<?php the_permalink() ?>" title="Compartilhar <?php the_title(); ?> no Facebook" target="_blank"><img src="<?php bloginfo('template_url'); ?>/img/fb.png" alt="" width="24" /></a></li>
            <li><a href="http://twitter.com/share?url=<?php the_permalink() ?>&amp;text=<?php the_title(); ?>&amp;via=chocoladesign" title="Compartilhar <?php the_title(); ?> no Twitter" target="_blank"><img src="<?php bloginfo('template_url'); ?>/img/tw.png" alt="" width="24" /></a></li>
          </ul>
        </section>
      </div>
      <?php endwhile; else: ?>
                <p><?php _e("Nenhum chocolate encontrado! :(", ''); ?></p>
                <?php endif; ?>

在下面,我有这个:

<div id="load-posts">
  <a href="#" class="button">Load more posts</a>
</div>

我的问题是:如何仅通过单击“加载更多帖子”链接就可以用ajax加载6个其他帖子。

我尝试了很多插件,但是没有成功。 :/

我想这样做: http : //designerthemes.com/preview/?theme=adapt

尝试使用pbd-ajax-load-posts插件。

以及一些我在此处发布到此插件的修复程序。 我在wordpress上“加载更多帖子”的代码错过了一些页面。 它出什么问题了?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM