我對WordPress很新,有一個問題。我已經創建了自己的主題,這似乎都很好。但是,我有一個問題。我想在我的主頁以外的頁面上創建我的博客頁面(包含所有帖子)。所以,在我的主題文件夾,我創建了一個名爲blog.php的頁面模板:在靜態頁面上顯示博客文章
<?php
/*
Template Name: blog
*/
?>
<?php get_header(); ?>
<table id="about-table" >
<tr>
<td colspan="7">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php the_title(); ?>
<?php the_author(); ?>
<?php the_time("jS F"); ?>
<?php comments_number("0","1","%"); ?>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>
</td>
</tr>
</table>
<?php get_footer(); ?>
然後,我在儀表板上的「網頁」部分中創建在WordPress有一個網頁叫做「博客」爲好,。然後,我將其模板分配到上面的「博客」模板。但問題是,代碼無法正常工作。它不顯示帖子的標題,評論等,而是顯示一些其他信息。另一方面,如果我只是複製此:
<table id="about-table" >
<tr>
<td colspan="7">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php the_title(); ?>
<?php the_author(); ?>
<?php the_time("jS F"); ?>
<?php comments_number("0","1","%"); ?>
<?php the_excerpt(); ?>
<?php endwhile; endif; ?>
</td>
</tr>
</table>
我的索引頁,它工作正常。那麼,如何在主頁以外的頁面上顯示我的所有發佈信息?
感謝您的答覆。當我運行你的代碼,雖然,我得到這個錯誤:致命錯誤:調用未定義的函數get_field() – jason
看看現在是否是正確的代碼,對不起,我忘了我有一個特殊的特色圖像代碼。 – gabearnold
再次感謝您的回覆。問題似乎與這部分:$ category = get_field('category_blog');雖然。我得到了一個缺少get_field函數的致命錯誤。我添加了get_images函數到我的funciton.php頁面,只是相同,但錯誤仍在繼續 – jason