Answer the question
In order to leave comments, you need to log in
Why can the metabox truncate the "?
Good afternoon. Created an additional field following an example from the network
function my_meta_box() {
add_meta_box(
'my_meta_box', // Идентификатор(id)
'My Meta Box', // Заголовок области с мета-полями(title)
'show_my_metabox', // Вызов(callback)
'post', // Где будет отображаться наше поле, в нашем случае в Записях
'normal',
'high');
}
add_action('add_meta_boxes', 'my_meta_box'); // Запускаем функцию
$meta_fields = array(
array(
'label' => 'текстовое поле',
'desc' => 'описание для поля.',
'id' => 'mytextinput', // даем идентификатор.
'type' => 'text' // Указываем тип поля.
// Начинаем выводить таблицу с полями через цикл
echo '<table class="form-table">';
foreach ($meta_fields as $field) {
// Получаем значение если оно есть для этого поля
$meta = get_post_meta($post->ID, $field['id'], true);
// Начинаем выводить таблицу
echo '<tr>
<th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
<td>';
switch($field['type']) {
case 'text':
echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="70" />
<br /><span class="description">'.$field['desc'].'</span>';
break;
"
for example , <a href="https://www.site
then the part after "
is simply cut off. Why is this happening and is there a recipe for how to fix it? By the way, while introducing this question here, the text was also cut off
Answer the question
In order to leave comments, you need to log in
By try to wrap :
It was
It became
$meta = get_post_meta($post->ID, $field['id'], true);
$meta = esc_attr($meta);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question