PHP Wordpress基本循环

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Wordpress基本循环相关的知识,希望对你有一定的参考价值。

<!-- if there are posts -->

<?php if (have_posts()) : ?> 

<!-- while there are posts -->

<?php while (have_posts()) : the_post(); ?>

<!-- the posts -->

<div class="post" id="post-<?php the_ID(); ?>">

<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

<!-- Custom field of "PostThumb" -->

<?php echo get_post_meta($post->ID, 'PostThumb',true); ?>

<!-- post meta -->

<p class="meta">
<span>Posted on</span><time datetime="<?php the_time('c');?>"><?php the_time();?></time> <span>by</span> <?php the_author(); ?>
</p>

<!-- get content / show "Read Full Article" link at break -->

<?php the_content('Read Full Article'); ?>

<!-- get tags -->

<p><?php the_tags('Tags: ', ', ', '<br />'); ?>

<!-- get category -->

Posted in <?php the_category(', '); ?>

<!-- get comments -->

<?php comments_popup_link('No Comments;','1 Comment', '% Comments'); ?></p>
</div>

<!-- end loop -->

<?php endwhile; ?>

<!-- show pagination links -->

<?php next_posts_link('Older Entries'); ?>
<?php previous_posts_link('Newer Entries'); ?>

<1-- if no posts -->

<?php else : ?>

<h2>Nothing Found</h2>

<?php endif; ?>

以上是关于PHP Wordpress基本循环的主要内容,如果未能解决你的问题,请参考以下文章

PHP Wordpress基本循环

添加第二个 Wordpress 循环,显示 single.php 中的最新帖子

php Wordpress循环/循环

php 循环WordPress

php WordPress - 自定义帖子类型循环

php wordpress:发布循环列表