Use it can be done using CUSTOM META BOX. Add following to function.php:
/* Adds pizza size meta box to the post editing screen
******************************************************/
function prfx_custom_meta() {
add_meta_box( 'prfx_meta', __( 'Pizza Size', 'prfx-textdomain' ), 'prfx_meta_callback', 'post' );
}
add_action( 'add_meta_boxes', 'prfx_custom_meta' );
/* Outputs the content of the meta box
**************************************/
function prfx_meta_callback( $post ) {
wp_nonce_field( basename( __FILE__ ), 'prfx_nonce' );
$prfx_stored_meta = get_post_meta( $post->ID );
?>
<p>
<label for="meta-text" class="prfx-row-title" style="clear:both; float: left; width:100%;" ><?php _e( '<b>Enter Pizza Size</b> ', 'prfx-textdomain' )?></label>
<textarea name="meta-text" id="meta-text" maxlength="250" style="clear:left; float: left; width: 100%;" rows="4" cols="90"><?php if ( isset ( $prfx_stored_meta['meta-text'] ) ) echo $prfx_stored_meta['meta-text'][0]; ?></textarea>
<p>You can write like: Available in: 21" and 16" only</p>
</p>
<?php
}
/* Saves the custom meta input
******************************/
function prfx_meta_save( $post_id ) {
// Checks save status
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[ 'prfx_nonce' ] ) && wp_verify_nonce( $_POST[ 'prfx_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
// Exits script depending on save status
if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
return;
}
// Checks for input and sanitizes/saves if needed
if( isset( $_POST[ 'meta-text' ] ) ) {
update_post_meta( $post_id, 'meta-text', sanitize_text_field( $_POST[ 'meta-text' ] ) );
}
}
add_action( 'save_post', 'prfx_meta_save' );
And then goto piece of code where you would like to show pizza sizes e.g I want to show it on single.php, so I will add the following code after description:
<?php $meta_value = get_post_meta( get_the_ID(), 'meta-text', true );
// Checks and displays the retrieved value
if( !empty( $meta_value ) )
echo $meta_value;
else
echo "No pizza sizes available";
?>