Display all post meta keys and meta values of the same post ID in wordpress

前端 未结 6 1674
长发绾君心
长发绾君心 2020-12-23 17:10

I\'m trying to display post meta values and post meta keys, If only one value is to be display I can used the simple function get_post_meta() but what I need now is to post

6条回答
  •  梦毁少年i
    2020-12-23 17:52

    I use it in form of a meta box. Here is a function that dumps values of all the meta data for post.

        function dump_all_meta(){
    
            echo "

    All Post Meta

    "; // Get all the data. $getPostCustom=get_post_custom(); foreach( $getPostCustom as $name=>$value ) { echo "".$name.""." => "; foreach($getPostCustom as $name=>$value) { echo "".$name.""." => "; foreach($value as $nameAr=>$valueAr) { echo "
         "; echo $nameAr." => "; echo var_dump($valueAr); } echo "

    "; } } // Callback funtion ended.

    Hope it helps. You can use it inside a meta box or at the front-end.

提交回复
热议问题