Merhaba arkadaşlar,
bir film teması üzerinde çalışmaktayım ve temada oyuncular, yönetmen gibi özel alanlar var,
ekran tercihlerinden özel alanları seçip eklenmekte bu oyuncular yönetmenler falan,
şimdi istediğim keremiya vb. film temalarında ki gibi, normal yazı ekleme menüsünün altında özel bir alan oluşturarak ekleme, bunu nasıl yapabiliriz?
yardımcı olabilecek varsa sevinirim.
özel alanları admin paneline ekleme
3
●1.646
- 16-01-2014, 20:09:07
- 16-01-2014, 20:41:20Türkçe bir kaynak olsaydı daya iyi olurdu,metin_nn adlı üyeden alıntı: mesajı görüntüle
- 16-01-2014, 23:41:44özelden mesaj atın okunmamis olarak saklayayim türkçe olarak konu altına çeviri yaparım

--R10.NET; Flood Engellendi -->-> Yeni yazılan mesaj 23:41:44 -->-> Daha önceki mesaj 22:05:44 --
Fonksiyon.php Eklemeniz Gereken Kodlar
add_action( 'admin_menu', 'sp_add_custom_box' ); add_action( 'save_post', 'sp_save_postdata', 1, 2 ); $sp_boxes = array ( 'DENEME BASLIK' => array ( array( 'ozel-alan-adi', 'deneme' ), array( 'ozel-alan-adi1', 'deneme1' ), array( 'ozel-alan-adi2', 'deneme 12' ), array( 'ozel-alan-adi3', 'deneme 123','textarea' ), ), ); function sp_add_custom_box() { global $sp_boxes; if ( function_exists( 'add_meta_box' ) ) { foreach ( array_keys( $sp_boxes ) as $box_name ) { add_meta_box( $box_name, __( $box_name, 'sp' ), 'sp_post_custom_box', 'post', 'normal', 'high' ); } } } function sp_post_custom_box ( $obj, $box ) { global $sp_boxes; static $sp_nonce_flag = false; if ( ! $sp_nonce_flag ) { echo_sp_nonce(); $sp_nonce_flag = true; } foreach ( $sp_boxes[$box['id']] as $sp_box ) { echo field_html( $sp_box ); } } function field_html ( $args ) { switch ( $args[2] ) { case 'textarea': return text_area( $args ); case 'checkbox': case 'radio': case 'text': default: return text_field( $args ); } } function text_field ( $args ) { global $post; $args[2] = get_post_meta($post->ID, $args[0], true); $args[1] = __($args[1], 'sp' ); $label_format = '<label for="%1$s">%2$s</label><br />' . '<input style="width: 95%%;" type="text" name="%1$s" value="%3$s" /><br /><br />'; return vsprintf( $label_format, $args ); } function text_area ( $args ) { global $post; $args[2] = get_post_meta($post->ID, $args[0], true); $args[1] = __($args[1], 'sp' ); $label_format = '<label for="%1$s">%2$s</label><br />' . '<textarea style="width: 95%%;" name="%1$s">%3$s</textarea><br /><br />'; return vsprintf( $label_format, $args ); } function sp_save_postdata($post_id, $post) { global $sp_boxes; if ( ! wp_verify_nonce( $_POST['sp_nonce_name'], plugin_basename(__FILE__) ) ) { return $post->ID; } if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post->ID )) return $post->ID; } else { if ( ! current_user_can( 'edit_post', $post->ID )) return $post->ID; } foreach ( $sp_boxes as $sp_box ) { foreach ( $sp_box as $sp_fields ) { $my_data[$sp_fields[0]] = $_POST[$sp_fields[0]]; } } foreach ($my_data as $key => $value) { if ( 'revision' == $post->post_type ) { return; } $value = implode(',', (array)$value); if ( get_post_meta($post->ID, $key, FALSE) ) { update_post_meta($post->ID, $key, $value); } else { add_post_meta($post->ID, $key, $value); } if (!$value) { delete_post_meta($post->ID, $key); } } } function echo_sp_nonce () { echo sprintf( '<input type="hidden" name="%1$s" id="%1$s" value="%2$s" />', 'sp_nonce_name', wp_create_nonce( plugin_basename(__FILE__) ) ); } if ( !function_exists('get_custom_field') ) { function get_custom_field($field) { global $post; $custom_field = get_post_meta($post->ID, $field, true); echo $custom_field; } }
Bu Alanı Düzenleyerekte Gerekli Açıklamaları Yapabilirsiniz HTML kodlar kullanıp şekillendirebilirsiniz.
$sp_boxes = array ( 'DENEME BASLIK' => array ( array( 'ozel-alan-adi', 'deneme' ), array( 'ozel-alan-adi1', 'deneme1' ), array( 'ozel-alan-adi2', 'deneme 12' ), array( 'ozel-alan-adi3', 'deneme 123','textarea' ), ), );
Konu içerisinde Kullanımı
<?php echo get_post_meta($post->ID, "ozel-alan-adi", true); ?>
<?php echo get_post_meta($post->ID, "ozel-alan-adi1", true); ?>
Bu şekilde isteklerinizi karşılayabilirsiniz kolay gelsin başarılar.
