views:

120

answers:

3

I know you can easily add custom meta boxes per post type, but I'm looking to add a custom meta box / custom field for a specific page without getting away from the wordpress 'pages' menu.

So for example, when I go to Pages-> Edit 'Home' a box called welcome text shows up.

If I edit the page 'About', that box wont show up.

Any ideas?

A: 

You should be able to use the Custom_Fields property on the pages you want to add data to. For example. On the "Home" page add a custom field "welcome_text" then use something like

$customField = get_post_custom_values("welcome_text");
if (isset($customField[0])) {
    echo $customField[0];
}  

inside the home template. I'm sure there are other ways but this may be the simpliest.

BandonRandon
Sorry i mean in the wordpress editor, I only want the edit fields to show up if that page has them...
Wes
A: 

If you want to decide on the edit page whether to add a meta box or not, hook into the add_meta_boxes or add_meta_boxes_page (for the page post type) actions. They are called right before the boxes are drawn, so you can choose to add one via add_meta_box.

Jan Fabry
A: 

Perhaps WPAlchemy MetaBox might help...

farinspace