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."   <".$bc_star_size_value." style=\"display:inline-block;margin:-20px 0px 20px 0px;\">☆"; break; case 2: //if value 2 selected the Two star will be displayed $new_content .= $bc_text_field_value."   <".$bc_star_size_value." style=\"display:inline-block;margin:-20px 0px 20px 0px;\">☆ ☆"; break; case 3: //if value 3 selected the Three star will be displayed $new_content .= $bc_text_field_value."   <".$bc_star_size_value." style=\"display:inline-block;margin:-20px 0px 20px 0px;\">☆ ☆ ☆"; break; case 4: //if value 4 selected the four star will be displayed $new_content .= $bc_text_field_value."   <".$bc_star_size_value." style=\"display:inline-block; margin:-20px 0px 20px 0px;\">☆ ☆ ☆ ☆"; break; case 5: //if value 5 selected the five star will be displayed $new_content .= $bc_text_field_value."   <".$bc_star_size_value." style=\"display:inline-block;margin:-20px 0px 20px 0px;\">☆ ☆ ☆☆ ☆"; break; default: $new_content .= "Difficulty level not set for this Post"; } //Show the rating on home and post if($homeonly=='1' && $postonly=='1'){ if( is_home() || is_singular() || is_archive() || is_category() ){ //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; } } //Show the rating only on home else if($homeonly=='1' && $postonly=='0') if( is_home() || is_front_page() || is_archive() || is_category()){ //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; } else{return $content;} //Show the rating only on Post else if($postonly=='1' && $homeonly=='0') if( is_singular()){ //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; } else{return $content;} } #filter to add the above function after the content add_filter( 'the_content', 'buffercode_meta_content' ); //////////////////////////////////////////////////////////// //Adding difficulty level star to post list admin dashboard// add_filter('manage_posts_columns', 'article_bc_columns_head'); add_action('manage_posts_custom_column', 'article_bc_columns_content', 10, 2); function article_bc_columns_head($defaults) { //$meta_value=get_post_meta($post->ID, 'buffercode_meta_value_key',true); $defaults['meta_value_col'] = 'Difficulty Level'; return $defaults; } function article_bc_columns_content($column_name, $post_id) { if ($column_name == 'meta_value_col') { $meta_value_star=get_post_meta( $post_id, 'buffercode_meta_value_key', true ); switch($meta_value_star) { case 1: echo '

'; break; case 2: echo '

☆ ☆

'; break; case 3: echo '

☆ ☆ ☆

'; break; case 4: echo '

☆ ☆ ☆ ☆

'; break; case 5: echo '

☆ ☆ ☆ ☆ ☆

'; break; default: echo 'Not Rated'; } } } ?>