[英]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&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() ?>&text=<?php the_title(); ?>&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個其他帖子。
我嘗試了很多插件,但是沒有成功。 :/
嘗試使用pbd-ajax-load-posts插件。
以及一些我在此處發布到此插件的修復程序。 我在wordpress上“加載更多帖子”的代碼錯過了一些頁面。 它出什么問題了?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.