【架構篇】WordPress佈景主題製作【page.php】

【架構篇】WordPress佈景主題製作【page.php】

本篇要來介紹製作WordPress佈景主題之一的page.php 檔案,page.php 又稱為頁面,主要是用於像是關於我們、所有文章、隱私權…等等類似公告頁面,其實跟 single.php 很像,頁面就比較屬於像是公告方面的用途,像是可以移除留言板、分享文章的功能…等等。

秀出頁面內容

像之前 index.php 作法一樣,先取得之前 header.php、footer.php、sidebar.php 短碼語法引用到 page.php。

<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

取得頁面標題。

<?php the_title(); ?>

接下來使用 while 循環來秀出接下來的顯示項目,the_content() 則是秀出單篇(這篇)文章內容,最後在 endwhile 結束循環。

<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>

完整語法結構:

<?php get_header(); ?>
<?php the_title(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

關於WordPress系列文章事項
文章版本:
第 2.0 版本,WordPress 系列教學純屬個人經驗,若有錯誤會重新修正並加上版本號碼,目前會持續調整樣式、整理佈景語法,目前版本已調整為先教學基本架構再教學設計樣式,之後會以最終版本告知。

相關文章
作者簡介
個人頭像照片
努力寫文中!