(一) 比如新建聯繫我們頁面
在主題下面建立contact.php,然後寫入以下代碼
<?php
/* Template Name: 【聯繫我們】模板頁 */
?>
<?php get_header() ?>
<?php get_footer() ?>
後臺新建頁面模板中有了該模板。
接下來在後臺新建頁面中添加標題、內容,然後發佈或者更新。
調用數據庫中的post
<!--文章主循環查詢開始-->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<!--文章主循環查詢結束-->
修改永久鏈接。
(二)
新建立page-news.php
把 page.php 文件重命名爲 page-news.php,其中news 就是新聞頁面固定鏈接 https://******.com/news後面的那個,這個文件名字一定要跟我們新建頁面的固定鏈接相一致;