回路http://codex.wordpress.org/The_Loop
这里有一个标准循环,您可以使用WP\\u查询进行自定义。
<?php
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo \'<ul>\';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo \'<li>\' . get_the_title() . \'</li>\';
}
echo \'</ul>\';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
http://codex.wordpress.org/Class_Reference/WP_Query
您可以使用get\\u template\\u part、模板标记或将其硬编码到循环中,将\\u内容和条目元添加到循环中。
这是一首包含在214首主题单曲中的循环曲。php文件。
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( \'content\', get_post_format() );
// Previous/next post navigation.
twentyfourteen_post_nav();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->
<?php
get_sidebar( \'content\' );
get_sidebar();
get_footer();
作者姓名包含在帖子信息中,在214个主题中,作者姓名被编码为模板标记
if ( ! function_exists( \'twentyfourteen_posted_on\' ) ) :
/**
* Print HTML with meta information for the current post-date/time and author.
*/
function twentyfourteen_posted_on() {
// Set up and print post meta information.
printf( \'<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>\',
esc_url( get_permalink() ),
esc_attr( get_the_date( \'c\' ) ),
esc_html( get_the_date() ),
esc_url( get_author_posts_url( get_the_author_meta( \'ID\' ) ) ),
get_the_author()
);
}
endif;
然后,模板标记将包含在内容中。php文件
twentyfourteen_posted_on();
以及内容。php包含在单个中。使用get\\u template\\u part的php文件。
get_template_part( \'content\' );