PHP Developer

Showing posts with label meta boxes. Show all posts
Showing posts with label meta boxes. Show all posts

Saturday, 25 October 2014

How To Get Custom Meta Box Value in WordPress

 How To Get Custom Meta Box Value in WordPress


<?php $id = post_id;?>  //Post id save in $id
<?php echo get_post_meta($id, '
origin', true );?>   // Get value of Metabox with meta_key name origin

<?php echo get_post_meta($id, 'preparation_time', true );?>   // Get value of Metabox with meta_key name preparation_time
<?php echo get_post_meta($id, 'amount_of_persons', true );?>   // Get value of Metabox with meta_key name amount_of_persons
<?php echo get_post_meta($id, 'benodigde_ingredienten', true );?>   // Get value of Metabox with meta_key name benodigde_ingredienten
<?php echo get_post_meta($id, 'bereiding', true );?>   // Get value of Metabox with meta_key name bereiding   

How To Create Custom Post With Meta Boxes Plugin In WordPress

How To Create Custom Post With Meta Boxes Plugin In WordPress


<?php
/*
Plugin Name: Recipe Meta Box
Plugin URI:
Description: With the help of this plugin you can add recipe detail where add post or create recipe for your project.
Author: Sunil Sharma
Author URI: https://plus.google.com/u/0/115833273431242118637
*/

$paths = ABSPATH;
include_once $paths.'wp-load.php';

/*--------------------------------Create Custom Post Code Start---------------------------------------*/
function recipe_init() {
    $args = array(
      'public' => true,
      'label'  => 'Recipe Code',
      'supports'  => array( 'title', 'editor', 'thumbnail' )
    );   
    register_post_type( 'recipe', $args );   
}
add_action( 'init', 'recipe_init' );
/*--------------------------------Create Custom Post Code End---------------------------------------*/