Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The theme I purchased came without custom fields in the post/product editor. It uses a custom post type in its own admin php file. I've managed to add custom fields by pulling the following code out of wordpress core metabox.php file however I'm unsure how to get it to work. Its missing the area where the custom field values should go.

<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php
$metadata = has_meta($post->ID);
list_meta($metadata);
meta_form(); ?>
</div>
share|improve this question
    
This sounds like it might be a support issue for the theme. Have you contact the vendor? –  MikeSchinkel Feb 3 '11 at 13:00
    
You can't simply call in the markup for the fields and expect it to work, there's a bunch of ajax functionality that's tied to the custom fields, replicating that inside some custom administration page isn't going to be a case of just printing out the appropriate HTML. As Mike said, this may really be a question that should be raised with the theme developer(s). –  t31os Feb 3 '11 at 13:36
    
Thanks, I'm pretty sure I'm not going to get any help out of the developer, his site is down at the moment as well. I was hoping that someone might know an easier way that I could just paste into the function file. I've made my own post type with custom fields however trying to implement it into the theme is going to be a pita. –  user2913 Feb 3 '11 at 13:53

3 Answers 3

Is display of the "Custom Fields" metabox enabled for your Custom Post Type's Edit Screen?

To check:

1) Edit (Post Type) Screen 2) Click the "Screen Options" tab in the upper right-hand corner 3) Ensure the "Custom Fields" checkbox is enabled

WordPress 3.1 made some (ahem) decisions regarding which metaboxes should display by default on the Edit screens. In some cases, previously displayed metaboxes were changed not to display by default.

share|improve this answer

Are you sure support for custom fields is implemented at all? Support of meta for custom post type must be declared in supports argument in register_post_type() or separate add_post_type_support() call.

That would cover WP native edit controls, not sure how (if at all) that applies to custom page of your theme, might be better question for its developer indeed.

share|improve this answer
    
It is in the setup file however it doesn't seem to make use of the support array at all. –  user2913 Feb 3 '11 at 13:30
1  
$args = array( 'labels' => array('Products'), 'public' => true, 'publicly_queryable' => true, 'show_ui' => false, 'show_in_menu' => false, 'query_var' => true, 'rewrite' => true, // Permalinks 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'taxonomies' => array('category', 'filter', 'post_tag'), 'supports' => array('title','editor','author',custom-field','thumbnail','excerpt','comments'), //'_edit_link' => 'post.php?post=%d', ); register_post_type('product', $args); –  user2913 Feb 3 '11 at 13:31
1  
@steen: Syntactical error on your supports array. Missing a single quote ' –  Zack Feb 4 '11 at 18:09

In your theme files look for the code that registers the custom post type most likely using the register_post_type() function and in its arguments array where it says 'supports' => ... Add 'custom-fields' to that string.

share|improve this answer
    
The setup file has custom-fields in the register_post_type array the theme doesn't seem to make use of it at all. It has its own processing for fields if that helps. In an admin add product processing file. –  user2913 Feb 3 '11 at 13:36
    
if (!empty($_GET['p'])){ $post = get_post($_GET['p']); if (!empty($post) && $post->post_type != 'product'){ $error = __('Invalid product ID','re'); } $product['id'] = $post->ID; $product['title'] = $post->post_title; $product['desc'] = $post->post_content; $product['desc'] = $post->post_content; $product['status'] = $post->post_status; $product['images'] = get_post_meta($post->ID, 'tgt_product_images', true); $product['url'] = get_post_meta($post->ID, 'tgt_product_url', true); –  user2913 Feb 3 '11 at 13:37
    
@steen: You can edit your question to include this code. The comments are too small for them. –  Jan Fabry Feb 3 '11 at 13:42
    
well then without seeing the code its hard to say but maybe you have a remove_meta_box function there to remove the default custom fields metabox. –  Bainternet Feb 3 '11 at 15:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.