admin管理员组文章数量:1023794
I'm using list category posts and would like to display several custom fields, but not all together.
I have used a template to display the list in a table, and have custom fields for country, county and town that I would like to display in individual cells. These are the only custom fields I will be using, so I can hard code the names in the template is necessary.
Thanks.
I'm using list category posts and would like to display several custom fields, but not all together.
I have used a template to display the list in a table, and have custom fields for country, county and town that I would like to display in individual cells. These are the only custom fields I will be using, so I can hard code the names in the template is necessary.
Thanks.
Share Improve this question asked Apr 3, 2012 at 13:53 mary hughesmary hughes 312 bronze badges1 Answer
Reset to default 1You can use get_post_meta(). This is the codex article: http://codex.wordpress/Function_Reference/get_post_meta
It sounds like each of the custom field values you want to display would only contain one result (one country, one town etc). In that case you'd use something like this in your template, wherever you want to display the value:
<?php if ( get_post_meta($post->ID, 'country', true) ) : ?>
<?php echo get_post_meta($post->ID, 'country', true) ?>
<?php endif; ?>
Hope this helps, best of luck!
I'm using list category posts and would like to display several custom fields, but not all together.
I have used a template to display the list in a table, and have custom fields for country, county and town that I would like to display in individual cells. These are the only custom fields I will be using, so I can hard code the names in the template is necessary.
Thanks.
I'm using list category posts and would like to display several custom fields, but not all together.
I have used a template to display the list in a table, and have custom fields for country, county and town that I would like to display in individual cells. These are the only custom fields I will be using, so I can hard code the names in the template is necessary.
Thanks.
Share Improve this question asked Apr 3, 2012 at 13:53 mary hughesmary hughes 312 bronze badges1 Answer
Reset to default 1You can use get_post_meta(). This is the codex article: http://codex.wordpress/Function_Reference/get_post_meta
It sounds like each of the custom field values you want to display would only contain one result (one country, one town etc). In that case you'd use something like this in your template, wherever you want to display the value:
<?php if ( get_post_meta($post->ID, 'country', true) ) : ?>
<?php echo get_post_meta($post->ID, 'country', true) ?>
<?php endif; ?>
Hope this helps, best of luck!
本文标签: pluginlistcategorypost custom fields
版权声明:本文标题:plugin-list-category-post custom fields 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745566485a2156479.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论