پیام وضعیت برای پست ها در وردپرس

اگر جزء افرادی باشید که علاقه به سفارشی تر کردن وردپرس خود دارید تا مدیریت برای شما آسان تر شود ، شاید دوست داشته باشید تا وضعیت مطالب خود را کنار آنها درج کنید ! مثلا مطالب جدید ، مطالب داغ ،تصاویر،ویدئو و … ! شما در این مطلب اضافه کردن یک پیام وضعیت زیبا را به پست ها در بخش مدیریت  فرا می گیرید که هم جالب و هم کاربردی است . برای خواندن آموزش به ادامه مطلب مراجعه کنید .

status

برای اضافه کردن این امکان کد زیر را در فایل functions.php پوسته خود قرار دهید .

add_filter( 'display_post_states','custom_post_state');
function custom_post_state( $states ) {
global $post;
$show_custom_state = get_post_meta( $post->ID, '_status' );
if ( $show_custom_state ) {
$states[] = __( '<span class='.$show_custom_state[0].'>'.$show_custom_state[0].'</span>' );
}
return $states;
}
add_action( 'post_submitbox_misc_actions', 'custom_status_metabox' );
function custom_status_metabox(){
global $post;
$custom  = get_post_custom($post->ID);
$status  = $custom["_status"][0];
$i   = 0;
/* ----------------------------------- */
/*   Array of custom status messages            */
/* ----------------------------------- */
$custom_status = array(
'جدید',
'داغ',
'عکس',
'ویدئو',
);
echo '<div>';
echo '<label>وضعیت: </label><select name="status">';
echo '<option>وضعیت</option>';
echo '<option>-----------------</option>';
for($i=0;$i<count($custom_status);$i++){
if($status == $custom_status[$i]){
echo '<option value="'.$custom_status[$i].'" selected="true">'.$custom_status[$i].'</option>';
}else{
echo '<option value="'.$custom_status[$i].'">'.$custom_status[$i].'</option>';
}
}
echo '</select>';
echo '<br /></div>';
}
add_action('save_post', 'save_status');
function save_status(){
global $post;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ return $post->ID; }
update_post_meta($post->ID, "_status", $_POST["status"]);
}
add_action( 'admin_head', 'status_css' );
function status_css() {
echo '<style type="text/css">
.default{font-weight:bold;}
.custom{border-top:solid 1px #e5e5e5;}
.custom_state{
font-size:9px;
color:#666;
background:#e5e5e5;
padding:3px 6px 3px 6px;
-moz-border-radius:3px;
}
/* ----------------------------------- */
/*   change color of messages bellow            */
/* ----------------------------------- */
.Spelling{background:#4BC8EB;color:#fff;}
.Review{background:#CB4BEB;color:#fff;}
.Errors{background:#FF0000;color:#fff;}
.Source{background:#D7E01F;color:#333;}
.Rejected{background:#000000;color:#fff;}
.Final{background:#DE9414;color:#333;}
</style>';
}
نویسنده مطلب
علی پامناری

دیدگاه کاربران

این وب سایت متعلق است به آذین وب (طراحی سایت در اصفهان) و تمامی حقوق آن محفوظ است.

طـبق ماده 12 فصل سوم قانون جرائم رایانه ای هرگونه کپی برداری از قالب پیگرد قانونی دارد.