احمد
1 ماه پیش توسط احمد مطرح شد
1 پاسخ

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

سلام
من کد یه متاباکس رو دارم ( ویرایشگر متن ) میخوام به صفحه single,php اضافه کنم
کد متاباکس که در فانکشن قرار میدم

=>  
<?php  
function custommetabox() {  
addmetabox(  
'customwysiwygmetabox',  
'Custom WYSIWYG Meta Box',  
'customwysiwygmetaboxcallback',  
'post',  
'normal',  
'high'  
);  
}  
addaction('addmetaboxes', 'custommetabox');
function custom_wysiwyg_meta_box_callback($post) {
    wp_nonce_field(basename(__FILE__), 'custom_wysiwyg_nonce');

    $content = get_post_meta($post->ID, '_custom_wysiwyg_content', true);

    wp_editor($content, 'custom_wysiwyg_editor');
}

function save_custom_wysiwyg_content($post_id) {
    if (!isset($_POST['custom_wysiwyg_nonce']) || !wp_verify_nonce($_POST['custom_wysiwyg_nonce'], basename(__FILE__))) {
        return $post_id;
    }

    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }

    if (isset($_POST['custom_wysiwyg_editor'])) {
        update_post_meta($post_id, '_custom_wysiwyg_content', $_POST['custom_wysiwyg_editor']);
    }
}
add_action('save_post', 'save_custom_wysiwyg_content');
?>

و کد برای قرار دادان در single.php =>

<?php echo getpostmeta( gettheID(), 'ustomwysiwygmetaboxcallback','customwysiwygmetabox', true ) ; ?>  

الان متاباکس در داشبورد زیر نوشنه ها نمایش داده میشه اما بعد انتشار پست در صفحه پست نمایش داده نمیشه

مشکل از کجاست؟؟؟


ثبت پرسش جدید
oss_vahid
تخصص : wordpress developer
@ossvahid 1 ماه پیش مطرح شد
0
wp_editor($content, 'custom_wysiwyg_editor');

تابع wp_editor ارگومان دومی آیدی تکست آریا هستش نه نیمش

$content = "";
$custom_editor_id = "editorid";
$custom_editor_name = "editorname";
$args = array(
        'media_buttons' => false, // This setting removes the media button.
        'textarea_name' => $custom_editor_name, // Set custom name.
        'textarea_rows' => get_option('default_post_edit_rows', 10), //Determine the number of rows.
        'quicktags' => false, // Remove view as HTML button.
    );
wp_editor( $content, $custom_editor_id, $args );

طبق اطلاع من وردپرس پیشنهاد میکنه از wp_editor داخل متاباکس استفاده نکنید

NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason running wp_editor() inside of a meta box is not a good idea unless only Quicktags is used.


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام