你好,我想创建一个有更新博客条目的主页。所以4个不同类别的标题列表
我想有一个链接到普通的博客页面与不同的模板。
现在我只是改变了index.php周围有特色文章内容的容器。
这是一个两部分的问题我如何得到这些东西的小更新我想多次使用query_posts(),并按类别分开。
和我如何使一个可链接的页面到一个blog.php文件,目前告诉我,所有这些函数是未定义的。
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer(); ?>
如果你想创建一个包含主题或博客文件夹之外的WP数据/帖子的页面,你需要首先包含并使Wordpress功能可用:
define('WP_USE_THEMES', false);
require('./blog/wp-blog-header.php');
然后您可以按类别查询每组帖子:
$args = array( 'numberposts' => '5, 'offset'=> 1, 'category' => 'your category ID' );
$myposts = get_posts( $args );
foreach($myposts as $post) {
...some code...
}