2013-09-05 32 views
2

我需要在表格中显示我的WordPress自定义页面上的一些元值。有什么办法可以做到这一点。如何显示表格中的Wordpress自定义页面的_meta()

这是我现在使用的代码:<?php the_meta(); ?>

而这正是它表明:

enter image description here

我想要做的事,如:

enter image description here

我发现:

the_meta()位于WP-包括/-的template.php后

这使得输出:

<ul class='post-meta'> 
<li><span class='post-meta-key'>your_key:</span> your_value</li> 
</ul> 

所以不建议因为该文件夹中编辑文件wordpress更新。

回答

2

你可以在HTML中的表和单独显示每个值,就像这样:

<?php echo get_post_meta($post->ID, 'Yout key', true); ?> 

Here的文档

+1

你的代码是非常有帮助的。谢谢! – Frankolin

1
<table> 
<tr><td colspan="2">Game Summary</td></tr> 
<?php 
$meta = get_post_meta(get_the_ID()); 
$exclude = array('_edit_last', '_wp_page_template', '_edit_lock'); 
foreach($meta as $key => $value) { 
    if(in_array($key, $exclude)) 
     continue; 
    ?> 
    <tr> 
     <td><?php echo $key; ?></td> 
     <td><?php echo $value[0]; ?></td> 
    </tr> 
    <?php 
} 
?> 
</table> 
+1

感谢您的帮助!键出现,但不显示值,它显示“数组”。 – Frankolin

+1

替换下面的表格:​​<?php echo $ value [0]; ?> – Subharanjan

+1

它工作? http://meta.stackexchange.com/a/5235 – Subharanjan

相关问题