我剛剛創建了一個新的頁面模板,並且只想打印所有包含類別新聞的帖子。如何顯示類別爲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('
','
'); –