【发布时间】:2017-02-17 07:59:34
【问题描述】:
我刚刚创建了一个新的页面模板,想打印所有只包含新闻类别的帖子。
在工作时使用了这个基于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( '
', '
' );
标签: wordpress categories