implement more fields wordpress plugin
I've found this custom fields plugin - http://wordpress.org/extend/plugins/more-fields/
Now I'm just wonderin开发者_运维技巧g how to implement more fields, I've installed the plugin, created fields, and added in field content to a post but nothing is being displayed on the front end...
I've search around and haven't be able to find any documentation on how to do this.
How can I get the Fields to display on the front end?
At this point in time I would just as soon not use the More Fields plugin at all, as there are native functions that can do everything you probably want with custom fields.
Any post can be assigned custom fields - you do this through the post editor.
Then in any of your php files, use the function get_post_meta() to access these custom field values, using this syntax (must be done within the loop):
<?php
$meta_value = get_post_meta($post->ID, 'custom_field_name', true);
?>
or, if you want to just print the custom field value without assigning it to a variable, do this:
<?php
echo(get_post_meta($post->ID, 'custom_field_name', true));
?>
The only thing you need to change there is 'custom_field_name'; just substitute the name (key) of whatever custom field you want to access.
http://codex.wordpress.org/Custom_Fields
$pid = $post->ID;
$foo =get_post_meta("$pid", 'CustomFieldName', true);
echo $foo;
The more fields plugin auto-creates custom fields, arbitrary extra information for a post known as meta-data. In order to access this info, you need to call that info with php, using wordPress's funciton get_post_meta()
in your template.
With the more fields plugin use
<?php meta('XXX'); ?>
in your template, where you want to have the content of your Field.
XXX is the name you enter in the Custom field key.
精彩评论