رفتن به مطلب

ساخت متاباکس در صفحه دسته بندی ها


پست های پیشنهاد شده

سلام دوستان می خواستم بدونم چطوری می تونم متاباکس در صفحه ساخت دسته بندی ها (category) یا دسته اختصاصی (singer) اضافه کنم؟

post type رو category دادم ولی نشد

اگه امکانش هست راهنماییم کنید

لینک به ارسال

یه کم بیشتر توضیح میدم شاید دوستان تونستن کمک کنن

من یه texonomy سفارشی ساختم به این شکل


function get_singer_texonomy(){
register_taxonomy('singer',array (
0 => 'photo',
1 => 'video',
2 => 'news',
3 => 'music',
4 => 'album',
5 => 'attachment',
),array( 'hierarchical' => true, 'label' => 'Artist','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => 'singer'),'singular_label' => 'Artist') );
}

حالا میخوام تو بخش مدیریتش یعنی جایی که یه دسته جدید میسازیم چند تا فیلد اضافه کنم یه جورایی شبیه به متاباکس

تو سایت های ایرانی گشتم چیزی پیدا نکردم تو سایت های خارجی یه چیزایی پیدا کردم ولی نتونستم برای texonomy سفارشی پیادش کنم کداش به این شکل


// A callback function to add a custom field to our "presenters" taxonomy
function presenters_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you're editing
$t_id = $tag->term_id; // Get the ID of the term you're editing
$term_meta = get_option( "taxonomy_term_$t_id" ); // Do the check
?>

<tr class="form-field">
<th scope="row" valign="top">
<label for="presenter_id"><?php _e('WordPress User ID'); ?></label>
</th>
<td>
<input type="text" name="term_meta[presenter_id]" id="term_meta[presenter_id]" size="25" style="width:60%;" value="<?php echo $term_meta['presenter_id'] ? $term_meta['presenter_id'] : ''; ?>"><br />
<span class="description"><?php _e('The Presenter\'s WordPress User ID'); ?></span>
</td>
</tr>

<?php
}
// A callback function to save our extra taxonomy field(s)
function save_taxonomy_custom_fields( $term_id ) {
if ( isset( $_POST['term_meta'] ) ) {
$t_id = $term_id;
$term_meta = get_option( "taxonomy_term_$t_id" );
$cat_keys = array_keys( $_POST['term_meta'] );
foreach ( $cat_keys as $key ){
if ( isset( $_POST['term_meta'][$key] ) ){
$term_meta[$key] = $_POST['term_meta'][$key];
}
}
//save the option array
update_option( "taxonomy_term_$t_id", $term_meta );
}
}
// Add the fields to the "presenters" taxonomy, using our callback function
add_action( 'presenters_edit_form_fields', 'presenters_taxonomy_custom_fields', 10, 2 );

// Save the changes made on the "presenters" taxonomy, using our callback function
add_action( 'edited_presenters', 'save_taxonomy_custom_fields', 10, 2 );

لطفا اگه کسی میتونه راهنماییم کنه !

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...