Hide Custom Fields in New Post?

余生颓废 提交于 2019-12-12 01:30:10

问题


I just started out with WordPress and I'm having some problems with the custom fields. Here's the code from functions.php

add_post_meta($post_id, 'Post Thumbnail', $post_thumb, true) or update_post_meta($post_id, 'Post Thumbnail', $post_thumb);
add_post_meta($post_id, 'Project URL', $url, true) or update_post_meta($post_id, 'Project URL', $url);
add_post_meta($post_id, 'Project Thumbnail', $thumb, true) or update_post_meta($post_id, 'Project Thumbnail', $thumb);

The problem is that they show up when I try to create a new post like so:

alt text http://dl.getdropbox.com/u/118004/Screen%20shot%202010-05-12%20at%2010.45.35%20AM.png

The other problem is that they don't even work, only if I publish the post, go back and readd each field. Is there any way to hide the fields to only show the "Add new custom field:" part? Thank you!


回答1:


If end users don't need to edit them you can hide custom fields starting naming them with an underscore ('_'). see: http://codex.wordpress.org/Function_Reference/add_post_meta#Making_a_.22Hidden.22_Custom_Field

btw, I think it's better to avoid inserting spaces within custom fields keys.




回答2:


The following will help you create custom meta boxes:

http://farinspace.com/wordpress-meta-box-next-level/



来源:https://stackoverflow.com/questions/2816872/hide-custom-fields-in-new-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!