As a designer I'm not that well in PHP. I've created a (hybrid) meta box. Now I want to show the meta stuff on my template. For some reason I can't get it hooked in my template.

The meta box is saving stuff propperly.

function hybrid_service_meta_boxes() {

/* Array of the meta box options. */
$meta_boxes = array(
    'doc' => array( 'name' => 'doc', 'title' => __('doc', 'hybrid'), 'type' => 'text' ),
    'description' => array( 'name' => 'Description', 'title' => __('Description', 'hybrid'), 'type' => 'textarea' ),            

return apply_filters( 'hybrid_service_meta_boxes', $meta_boxes );}

The problem now is, how do I hook this up to the front?

<?php if ( get_post_meta($post->ID, 'Service', true) ) : ?>

Test succes

<?php endif; ?>

As you can see I'm testing if the stuff is working, but I won't get the 'test succes'.

Does anyone know what I'm doing wrong? I think 'Service' is incorrect..


Problem solved:

<?php echo get_post_meta( get_the_ID(), 'doc', true ) ?> 

'doc' fetches one of meta_boxes array items. Then you can echo them

And.. check if you are editing the right single.php (my mistake).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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