英文:
custom fields hidden when using Advanced custom field wordpress?
问题
Before using Advanced Custom Fields, I can show custom fields from screen options
for the page.
After installing Advanced Custom Fields, custom fields hidden from screen options
.
After I deactivate Advanced Custom Fields, they appear again.
Can I show custom fields after installing Advanced Custom Fields?
英文:
Before using Advanced Custom fields, I can show custom fields from screen options
for the page
After installing Advanced Custom Fields, custom fields hidden from screen options
.
After I deactivate Advanced custom fields, it appear again.
can I show custom fields after installing Advanced custom fields.
答案1
得分: 1
默认情况下,高级自定义字段会移除WordPress的默认自定义字段,因为它已经为您提供了可以添加的自定义字段。但是,如果您确实需要使用默认的客户字段,那么您可以为其创建自己的元框。以下是一个示例:
function add_custom_fields_to_pages() {
add_meta_box('custom_fields', 'Custom Fields', 'custom_fields_meta_box', 'page', 'normal', 'high');
}
function custom_fields_meta_box() {
global $post;
echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';
echo '<div>';
echo '<label for="custom_field">Custom Field</label>';
echo '<input type="text" name="custom_field" value="'.get_post_meta($post->ID, 'custom_field', true).'" />';
echo '</div>';
}
您可以更改它的名称,因为它只是一个新的元框。这里有另一个示例:https://www.smashingmagazine.com/2011/10/create-custom-post-meta-boxes-wordpress/
英文:
By Default The Advance Custom field removes the default custom field from WordPress. because it is already providing you with custom fields to be added.
But somehow if you really need to use the default customer field. then you can create your own meta boxes for that.
here is a sample example.
function add_custom_fields_to_pages() {
add_meta_box('custom_fields', 'Custom Fields', 'custom_fields_meta_box', 'page', 'normal', 'high');
}
function custom_fields_meta_box() {
global $post;
echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';
echo '<div>';
echo '<label for="custom_field">Custom Field</label>';
echo '<input type="text" name="custom_field" value="'.get_post_meta($post->ID, 'custom_field', true).'" />';
echo '</div>';
}
You can change the name of it because it is only a new meta box.
here is another example: https://www.smashingmagazine.com/2011/10/create-custom-post-meta-boxes-wordpress/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论