will be id for add_meta_box
2. Post Strength Mode => will be the Title for the meta box and it will be displayed in the admin dash board
3. buffercode_inner_post_mode => function to go with our busines logics.
*/
add_meta_box(
'buffercode_post_mode_id',
__( 'Post Strength Mode', 'buffercode_box' ),
'buffercode_inner_post_mode',
$buffercode_locations
);
}
}
#registering our meta boxes in admin dash board.
add_action( 'add_meta_boxes', 'buffercode_post_mode' );
function buffercode_inner_post_mode( $post ) {
// Add an nonce field so we can check for it later.
wp_nonce_field( 'buffercode_inner_post_mode', 'buffercode_inner_post_mode_nonce' );
/*
Get the value previous value from the database to display in the admin dashboard
*/
$value = get_post_meta( $post->ID, 'buffercode_meta_value_key', true );
#label to show the field Select the Difficult of this Post
echo ' '; ?>
ID, 'buffercode_meta_value_key',true); //Get the selected value from the admin dashboard
//$content .= $original;
switch($meta_value) //checking for the value selected
{
case 1: //if value 1 selected the one star will be displayed
$new_content .= $bc_text_field_value."
☆
";
break;
case 2: //if value 2 selected the Two star will be displayed
$new_content .= $bc_text_field_value."
☆ ☆
";
break;
case 3: //if value 3 selected the Three star will be displayed
$new_content .= $bc_text_field_value."
☆ ☆ ☆
";
break;
case 4: //if value 4 selected the four star will be displayed
$new_content .= $bc_text_field_value."
☆ ☆ ☆ ☆
";
break;
case 5: //if value 5 selected the five star will be displayed
$new_content .= $bc_text_field_value."
☆ ☆ ☆☆ ☆
";
break;
default:
echo "wrong value";
}
//If Rating selected to display above
if($bc_above_below_value=='above')
return $new_content.$content; //returning the orginal content and new content
else ////If Rating selected to display Below
return $content.$new_content;
}
#filter to add the above function after the content
add_filter( 'the_content', 'buffercode_meta_content' );
?>