在wordpress中显示信息全部帖子元键和同样帖子I

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 all post meta data with the same post_id. I tried using foreach loop but nothing displays. can you please check my codes?

function wpt_calendar_display()
 global $post;
 $columns = array(
 'date_event' = 'Date',
 'name_event' = 'Event'
 register_column_headers('list-header_events', $columns);
 $event_name = get_post_meta( $post- ID, '_event_name' );
 // $event_date = get_post_meta( $post- ID, '_event_date', false );
 $return .= " table "widefat\" 
 $return .= " tr 
 $return .= print_column_headers('list-header_events');
 $return .= " /tr 
 $return .= " tr 
 if (!empty($event_name))
 foreach($event_name as $e_name)
 $return .= " td 
 $return .= $e_name;
 $return .=" /td 
 $return .= " td 
 $return .= " /td 
 $return .= " /tr 
 $return .= " /table 
 return $return;
处理计划方案

Default Usage

Get the meta for all keys:


Note: some unwanted meta keys starting with "underscore(_)" will also come, so you will need to filter them out.


我正在尝试显示信息公布元值和公布元键,假如只显示信息1个值,我可使用简易的涵数get_post_meta(),可是我如今必须的是公布全部具备同样post_id的公布元数据信息。我尝试应用foreach循环系统,但沒有任何显示信息。



 涵数wpt_calendar_display()
{
全世界$ post;

$ columns = array(
'date_event'= 'Date',
'name_event'= 'Event'
);
register_column_headers('list-header_events',$ columns);

$ event_name = get_post_meta($ post- ID,__event_name');
// $ event_date = get_post_meta($ post- ID,‘_event_date’,false);

$ return。= table class = \ widefat\
$ return。= tr
$ return。= print_column_headers(’list-header_events’);
$ return。= / tr
$ return。= tr

if(!empty($ event_name))
foreach($ event_name as $ e_name)
{
$ return。= td
$ return。= $ e_name;
$ return。= / td

}

$ return。= td

$ return。= / td
$ return。= / tr
$ return。= / table
return $ return;
}

处理计划方案

默认设置用法



获得全部键的元数据信息:




 ?php $ meta = get_post_meta($ post_id); ? 



获得单独键的元数据信息:




 ?php $ key_1_values = get_post_meta(76,'key_1'); ? 


比如:



 $ myvals = get_post_meta($ post_id); 

foreach($ myvals as $ key = $ val)
{
echo $ key。 ’:’。 $ val [0]。 ’ br / ’;
}



留意:一些不必须的元键也会下列划线(_)开始,因而您必须将其过虑掉。