Turkish :
Arkadaşlar wp nin add_meta_box fonksiyonunu kullanarak özel alanlar ekletmeye çalışıyroum bunun için db de 2 tablo oluşturdum.Bunları Sayfa Ekleme Alanına Bastırıyorum. wp_turekle_meta_kategori tablosuna meta grublarını giriyorum wp_turekle_meta_field alanları tablosuna ise bu gruplara ait alanları giriyorum.Ancak ekrana basarken grupları listeliyor ve grupların içine sadece son eklenen wp_turekle_meta_field alanını basıyor.Kaç gündür çıkmaza girdim bu konuda yardımcı olurmusunuz şimdiden teşekkürler
English (Sorry Google Translate my english bad) :
Friends wp custom fields using the function included is the add_meta_box çalışıyroum for it in the db table oluşturdum.Bunları Page Adding a Zone 2 it low. I'm going grublarını table metadata fields wp_turekle_meta_kategori wp_turekle_meta_field screen printing groups giriyorum.Ancak table lists the fields belonging to these groups and groups entered into a stalemate just days recently added basıyor.Kaç wp_turekle_meta_field area could you help in this regard thanks in advance
wp_turekle_meta_kategori alanları = id,metaBoxId,metaBoxTitle,metaBoxPage,metaBoxContext,metaBoxPriority
wp_turekle_meta_field alanları = id,metaBoxKatId,fieldId,fieldName,fieldDesc,fieldType,fieldStd,fieldOptions
Kodlar
<?php
global $meta_box;
// add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
add_action('admin_menu', 'AlanOlustur');
function AlanOlustur() {
global $wpdb;
global $meta_box;
$metaKategoriCek = mysql_query("SELECT * FROM wp_turekle_meta_kategori");
while($metaKategoriCekYaz = mysql_fetch_array($metaKategoriCek)){
$kategoriId = $metaKategoriCekYaz['id'];
$metaBoxId = $metaKategoriCekYaz['metaBoxId'];
$metaBoxTitle = $metaKategoriCekYaz['metaBoxTitle'];
add_meta_box( $metaBoxId, $metaBoxTitle,'mytheme_show_box', 'wcb_tur', 'normal', 'high',$meta_box);
$metaFieldCek = mysql_query("SELECT * FROM wp_turekle_meta_field WHERE metaBoxKatId = '$kategoriId'");
while ($metaFieldYaz = mysql_fetch_array($metaFieldCek)){
$fieldId = $metaFieldYaz['id'];
$metaBoxKatId = $metaFieldYaz['metaBoxKatId'];
$fieldAlanId = $metaFieldYaz['fieldId'];
$fieldName = $metaFieldYaz['fieldName'];
$fieldDesc = $metaFieldYaz['fieldDesc'];
$fieldType = $metaFieldYaz['fieldType'];
$fieldStd = $metaFieldYaz['fieldStd'];
$fieldOptions = $metaFieldYaz['fieldOptions'];
$meta_box = array('fields' => array( array(
'id' => $fieldAlanId,
'name' => $fieldName,
'desc' => $fieldDesc,
'type' => $fieldType,
'std' => $fieldStd,
'options' => $fieldOptions
)));
}
}
}
function mytheme_show_box($meta_box) {
global $meta_box, $post;
// Use nonce for verification
echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
echo '<table class="form-table">';
foreach ($meta_box['fields'] as $field) {
// get current post meta data
$meta = get_post_meta($post->ID, $field['id'], true);
echo '<tr>',
'<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
'<td>';
switch ($field['type']) {
case 'text':
echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '
', $field['desc'];
break;
case 'textarea':
echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>', '
', $field['desc'];
break;
case 'select':
echo '<select name="', $field['id'], '" id="', $field['id'], '">';
foreach ($field['options'] as $option) {
echo '<option ', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
}
echo '</select>';
break;
case 'radio':
foreach ($field['options'] as $option) {
echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
}
break;
case 'checkbox':
echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
break;
}
echo '</td><td>',
'</td></tr>';
}
echo '</table>';
}