楊澤業:wordpress博客開發技巧之添加快遞查詢功能
今天我們就以增加快遞查詢的功能為例,講解知更鳥主題,新建一個獨立頁面應用的方法,並列出詳細的步驟,方便小白用戶實踐操作:
1、下載自己主題裏面的默認文章頁面,比如我的是page.php,位置在/wp-content/themes/begin目錄裏面,查看文件全部代碼為:
<?php get_header(); ?>
<div id="primary"
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template/content', 'page' ); ?>
<?php if ( comments_open() || get_comments_number() ) : ?>
<?php comments_template( '', true ); ?>
<?php endif; ?>
<?php endwhile; ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
2、我們在第一行的最前面添加一個頁面模板名稱為快遞查詢的代碼標識。
<?php
/*
Template Name: 快遞查詢
*/
?>
3、刪除默認文章頁面的<?php get_template_part( 'template/content', 'page' ); ?>這個頁面內容代碼。
4、到快遞100網站,獲取調用代碼,代碼為:
<iframe name="kuaidi100" src="https://www.kuaidi100.com/frame/730px.html" width="750" height="900" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
5、把這個頁面,另存為kuadi.php,保存格式為UFT-8。
6、把這個頁面上傳到上傳到博客主題系列單頁面模板列表,比如我的是放在wp-content/themes/begin/pages文件夾裏面。
7、後臺--頁面--新建頁面--填寫標題和固定網址,選擇模板頁面為快遞查詢的模板,點擊發布。(我已經發布過了,所以截圖中是更新)
發布成功以後,電腦和手機都瀏覽一下這個頁面看看是否正常,我這裏查看一切是正常的,
體驗地址:、
小夥伴們,你學會了開發wordpress新功能頁面了嗎?敢快去試試吧!
本文由楊澤業原創發布於51cto博客
楊澤業:wordpress博客開發技巧之添加快遞查詢功能