获取wordpress主题中的自定义字段值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取wordpress主题中的自定义字段值相关的知识,希望对你有一定的参考价值。

get custom fields value in wordpress theme
  1. To be used only inside WordPress’s Loop
  2.  
  3. <?php echo get_post_meta($post->ID, 'custom_field_name', true); ?>
  4.  
  5. It displays the value of the custom field. Replace “custom_field_name” with the chosen name of your custom field.
  6.  
  7. To display the value outside the loop use
  8.  
  9. <?php
  10. global $wp_query;
  11. $postid = $wp_query->post->ID;
  12. echo get_post_meta($postid, 'custom_field_name', true);
  13. ?>

以上是关于获取wordpress主题中的自定义字段值的主要内容,如果未能解决你的问题,请参考以下文章

片段中 ListView 的自定义适配器不起作用

如何从表格视图的自定义单元格内的文本字段中获取值(标签)以发布到 URL [重复]

根据 WooCommerce 中的自定义结帐单选按钮和文本字段设置动态费用

iOS:如何从 tableview 的自定义单元格中的 UITextField 访问值

如何在奏鸣曲中获取字段类型的自定义值?

从自定义适配器获取片段中的 UI 元素 ID