WordPress主題製作之模板檔案的引入方法,wordpress模板_PHP教程

來源:互聯網
上載者:User

WordPress主題製作之模板檔案的引入方法,wordpress模板


get_template_part() 用來引用模板檔案,類似於 get_header()、get_sidebar() 和 get_footer(),只不過這個 get_template_part() 可以引入自訂名字的檔案。

使用方法

get_template_part( $slug, $name );

參數

$slug

(字串)(必須)要引入的模板的檔案名稱,不包括尾碼名 .php,也就是如果需要引入當前主題根目錄的 loop.php 檔案 $slug 填寫 “loop” 即可。

預設:None

$name

(字串)(可選)要引入的模板的檔案的副檔案名稱,如果要引入當前主題根目錄的 loop-img.php 檔案 $slug 參數填寫 “loop”,$name 參數填寫 “img”。

預設值:None

傳回值

此函數無傳回值。

例子

引入當前主題根目錄的 endskin.com 檔案:

get_template_part( 'endskin' );

引入當前主題 part 目錄的 loop.php 檔案:

get_template_part( 'part/loop' );

引入當前主題根目錄的 endskin-com.php 檔案:

get_template_part( 'endskin', 'com' );

其它

此函數位於:wp-includes/general-template.php

您可能感興趣的文章:

  • WordPress的主題編寫中擷取頭部模板和底部模板
  • 講解WordPress中用於擷取評論模板和搜尋表單的PHP函數

http://www.bkjia.com/PHPjc/1085875.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1085875.htmlTechArticleWordPress主題製作之模板檔案的引入方法,wordpress模板 get_template_part() 用來引用模板檔案,類似於 get_header()、get_sidebar() 和 get_footer(),只不過...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.