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.

I have used a plugin called Amazon product in a post. It works okay with posts type. It adds custom fields in the posts page. But, I have made another custom post type called products. It does not work with that. I want the custom field appear in Products post type.

I have used few suggestions. Adding plugin in custom posts type but it did not work for me.

I have googled, tried several plugins but none of these seems to work. Can anyone suggest me another plugin or any other way to solve my purpose. What I want to do is, add amazon selected books to my website, in my custom post type pages. I have tried adding

if(function_exists('amazonProductInAPostBox1')){
    global $appipBulidBox;
    $custom_post_type = 'put-post-type-here';
    add_action('admin_menu', create_function("$appipBulidBox",
"if( function_exists( 'add_meta_box' ))add_meta_box( 'amazonProductInAPostBox1',
__( 'Amazon Product In a Post Settings', 'appplugin' ), 'amazonProductInAPostBox1', $custom_post_type, 'normal', 'high' );"));
}

But It did not seem to work. Thanks in advance

share|improve this question
    
I'm not sure you can use the variable $custom_post_type inside the newly created function without providing it as argument/paramenter. Try including it after the first (and only) argument $appipBulidBox (which is not being used so far...?). –  t f Mar 7 '13 at 17:53
1  
I did not understand exactly what you mean by that? Can you tell me clearly.? –  Suresh KUMAR Mukhiya Mar 7 '13 at 18:32
    
Well, I meant just to replace your add_action with this add_action('admin_menu', create_function("$appipBulidBox, $custom_post_type", "if( function_exists( 'add_meta_box' ))add_meta_box( 'amazonProductInAPostBox1', __( 'Amazon Product In a Post Settings', 'appplugin' ), 'amazonProductInAPostBox1', $custom_post_type, 'normal', 'high' );"));. I haven't tested that and I don't really get what you want to do (or what your problem is), but maybe that way you have access to the variable $custom_post_type. Anyway, what is the other argument $appipBulidBox for? You don't seem to use it. –  t f Mar 7 '13 at 19:24
    
NO luck. I want to add amazon products to my website. I add products to my website through custom post type called 'Products'. So, I have been trying to activate plugin for that custom post type. –  Suresh KUMAR Mukhiya Mar 8 '13 at 2:01

1 Answer 1

up vote 0 down vote accepted

Suresh what is the custom post type you want to hook into? You need to make sure you change the $custom_post_type = 'put-post-type-here'; line to be the actual custom post type slug you want to hook it into. Then, I would suggest adding the function to the functions.php. And try it this way:

add_action('admin_menu','new_appip_custom_post_type_metabox');
function new_appip_custom_post_type_metabox(){
     if(function_exists('amazonProductInAPostBox1') && function_exists( 'add_meta_box')){
         add_meta_box( 'amazonProductInAPostBox1','Amazon Product In a Post Settings', 'amazonProductInAPostBox1', 'put-post-type-here', 'normal', 'high' );
     }
     return;
}
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.