我想在稱爲「文章」的特定頁面上顯示所有帖子。如何獲取WordPress中特定頁面上的所有帖子標題
但是,當我在循環中使用the_title();
時,看起來這個頁面的標題被顯示。在articles.php
相對碼(鏈接到儀表盤創建的Articles
頁)
<div class="container">
<?php if (have_posts()) : ?>
<div class="content">
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php get_template_part('content', get_post_format()); ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
content.php
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post-header section medium-padding">
<div class="post-meta-top">
<?php the_time(get_option('date_format')); ?>
<?php
if (comments_open()) {
echo '<span class="sep">/</span> ';
if (is_single())
comments_popup_link('0 comments', '1 comment', '% comments', 'post-comments');
else
comments_number('0 comments', '1 comment', '% comments');
}
?>
</div>
<h2 class="post-title"><?php the_title(); ?></h2>
</a>
這部分工作良好index.php
。
你可以發佈你的循環代碼嗎? –
@Johann Kratzik我已經更新了我的問題。這部分工作在'index.php'中,但在'articles.php'中有問題,用作** Dashboard **中創建的頁面「文章」**的模板頁面。 –
這是你的全部代碼嗎?您需要使用頁面模板中的WP_Query()定義循環本身。否則只會顯示當前頁面循環。 –