WordPress帖子只显示第一篇文章的内容

时间:2017-08-22 19:55:29

标签: javascript php jquery html wordpress

我想从HTML模板创建一个WordPress主题,该模板使用jquery为从主页上发布的所有帖子的网格中打开的帖子设置动画。 我设法在主页上获得帖子网格,如下所示:

ahead

以及帖子的内容如下:

<?php
$args = array(
  'post_type'      => 'post',
  'posts_per_page' => $count,
  'paged'          => $paged,
);
$wp_query = new WP_Query( $args );
?>

<?php if ( $wp_query->have_posts() ) : ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>




        <a class="grid__item" href="<?php echo get_permalink() ?>">
  <!--Post data-->
                        <h1 class="title title--preview"><?php the_title(); ?></h1>
                        <div class="loader"></div>
                        <span class="category"><p><?php echo excerpt(10); ?></p></span>

                        <div class="meta meta--preview">
                            <?php the_post_thumbnail('thumbnail', array( 'class'=> 'meta__avatar')); ?>
                            <span class="meta__date"><i class="fa fa-calendar-o"></i><?php echo get_the_date(); ?></span>
                            <span class="meta__reading-time"><i class="fa fa-clock-o"></i> 2 min read</span>
                        </div>

</a>


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

和jquery代码:

<?php
$args = array(
  'post_type'      => 'post',
  'posts_per_page' => $count,
  'paged'          => $paged,
);
$wp_query = new WP_Query( $args );
?>

<?php if ( $wp_query->have_posts() ) : ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

  <section class="content">
    <div class="scroll-wrap">

            <article class="content__item">
                            <span class="category category--full">Life &amp; Death</span>
                            <h2 class="title title--full"><?php the_title(); ?></h2>
                            <div class="meta meta--full">
                                <!--<img class="meta__avatar" src="img/authors/4.png" alt="author04" />-->
                                <?php the_post_thumbnail('thumbnail', array( 'class'=> 'meta__avatar')); ?>
                                <span class="meta__author"><?php the_author(); ?></span>
                                <span class="meta__date"><i class="fa fa-calendar-o"></i><?php echo get_the_date(); ?></span>
                                <span class="meta__reading-time"><i class="fa fa-clock-o"></i> 2 min read</span>
                                <span class="meta__misc meta__misc--seperator"><i class="fa fa-comments-o"></i> 7 comments</span>
                                <span class="meta__misc"><i class="fa fa-heart"></i> 12 favorites</span>
                                <nav class="article-nav">
                                    <button><i class="fa fa-angle-left"></i> <span>Previous</span></button>
                                    <button><span>Next</span> <i class="fa fa-angle-right"></i></button>
                                </nav>
                            </div>
                            <p> <?php the_content(); ?></p>
                        </article>


    </div>

                <button class="close-button"><i class="fa fa-close"></i><span>Close</span></button>
</section>



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

然而,它仅显示最新帖子的内容,但是当我点击其他帖子时,它们只是空的。

0 个答案:

没有答案