用自定義字段可以擴展 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