我刚刚创建了一个新的页面模板,并且只想打印所有包含类别新闻的帖子。如何显示类别为news的帖子
使用此代码基于wordpress codex工作时。
<?php
query_posts(
array (
'post_type' => 'post',
'category_name' => 'news',
'category' => 1,
'posts_per_page' => 3)
);
// The Loop
while (have_posts()) : the_post();
the_title();
the_content();
endwhile;
// Reset Query
wp_reset_query();
?>
如何将标题换成h1标签并将内容换成div框?
我试过,但它给我语法错误:
<h1><?php the_title(); ?></h1>
希望能对你有所帮助。
使用任何一个category_name或category。 –
@Kushal Shah我刚刚删除了一个,但仍然没有显示 –
你可以像这样添加the_title('
','
'); –