用自定義欄位可以擴充套件 WordPress 文章的功能,在原有的基礎上無線擴充套件文章儲存的資訊。這些資訊一般都需要給訪客檢視,the_meta() 函式可以把所有的欄位列出來,展示文章的擴充套件資訊。

如果你要隱藏一些欄位,不想在這裡輸出出來,可以參考:https://www.weixiaoduo.com/hidden-custom-fields/

用法

引數

此函式無引數。

返回值

此函式無返回值。

例子

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

while(have_posts()):

    the_post();

    the_title('<h2 >','<h2>');

    the_content();

    the_meta();

    /*

        輸出程式碼結構:

        <ul >

            <li><span >views:</span> 2192</li>

            <li><span >favorites:</span> 2</li>

        </ul>

    */

endwhile;

其它

此函式位於:wp-includes/post-template.php

更多關於自定義欄位的文章:https://www.weixiaoduo.com/tag/custom-fields