ARS 349 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 درودمن برای استفاده از زمینه دلخواه یک متاباکس ایجاد کردم که مثلا نیاز نباشه هر بار دستی زمینه دلخواه رو وارد کنمبا استفاده از کد های زیر متا باکس اضافه شده ولی وقتی متنی رو وارد می کنم بعد ارسال مطلب رو که میزنم باکس ها خالی میشه و انگار نه انگار!ولی وقتی با استفاده زمینه دلخواه وارد می کنم بعد از ارسال مطلب در اون فیلد ها نمایش داده میشه!نمی دونم چی گفتم اصلا!!!<?php add_action("admin_init", "admin_init_meta_"); add_action('save_post', 'save_post_meta'); function admin_init_meta_(){ add_meta_box("prodInfo-meta", "اطلاعات نمونه کار", "meta_options", "samples", "normal", "high"); } function meta_options(){ global $post; $theme= get_post_meta( $post->ID, 'theme', true ); $details= get_post_meta( $post->ID, 'details', true ); $works= get_post_meta( $post->ID, 'works', true ); $site= get_post_meta( $post->ID, 'site', true ); $site= get_post_meta( $post->ID, 'more', true );?> <table border="0"> <tr> <td><label>قالب</label></td><td><input type="text" name="theme" value="<?php echo $theme; ?>" size="40" /></td> </tr> <tr> <td><label>تکنولوژی</label></td><td><input type="text" name="details" value="<?php echo $details; ?>" size="40" /></td> </tr> <tr> <td><label>خدمات انجام شده</label></td><td><input type="text" name="works" value="<?php echo $works; ?>" size="40" /></td> </tr> <tr> <td><label>آدرس سایت</label></td><td><input type="text" name="site" value="<?php echo $site; ?>" size="40" /></td> </tr><tr> <td><label>اطلاعات بیشتر</label></td><td><input type="text" name="site" value="<?php echo $more; ?>" size="40" /></td> </tr> </table><?php }function save_post_meta(){ global $post; $theme= get_post_meta( $post->ID, 'theme', true ); $details= get_post_meta( $post->ID, 'details', true ); $works= get_post_meta( $post->ID, 'works', true ); $site= get_post_meta( $post->ID, 'site', true ); $site= get_post_meta( $post->ID, 'more', true );}?> نقل قول لینک به ارسال
Mohammad 1620 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 به فانکشن اضافه کنید:add_action( 'save_post', 'cd_meta_box_save' );function cd_meta_box_save( $post_id ){ // Bail if we're doing an auto save if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; // if our nonce isn't there, or we can't verify it, bail if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return; // if our current user can't edit this post, bail if( !current_user_can( 'edit_post' ) ) return;} 3 نقل قول لینک به ارسال
ARS 349 ارسال شده در اردیبهشت 92 مالک گزارش بازنشر ارسال شده در اردیبهشت 92 مرسی محمد جان ولی کار نکرد! نقل قول لینک به ارسال
Parsa 23463 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 کدها را به ابتدای تابع ذخیره اضافه کنیدfunction save_post_meta(){// Bail if we're doing an auto save if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; // if our nonce isn't there, or we can't verify it, bail if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return; // if our current user can't edit this post, bail if( !current_user_can( 'edit_post' ) ) return; // more code 2 نقل قول لینک به ارسال
ARS 349 ارسال شده در اردیبهشت 92 مالک گزارش بازنشر ارسال شده در اردیبهشت 92 کدها را به ابتدای تابع ذخیره اضافه کنیدfunction save_post_meta(){// Bail if we're doing an auto save if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; // if our nonce isn't there, or we can't verify it, bail if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return; // if our current user can't edit this post, bail if( !current_user_can( 'edit_post' ) ) return;// more codeبازم تغییری نکرد! نقل قول لینک به ارسال
Parsa 23463 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 بخش ذخیره درست نیست 2 نقل قول لینک به ارسال
ARS 349 ارسال شده در اردیبهشت 92 مالک گزارش بازنشر ارسال شده در اردیبهشت 92 بخش ذخیره درست نیستhttp://forum.wp-pars...واه/#entry33902راستش چیزی متوجه نشدم ! یعنی یکم کدهارو دسکاری کردم ولی بازم نشد! نقل قول لینک به ارسال
Parsa 23463 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 با کدهای قبلی ترکیب کنیدfunction save_post_meta($post_id){ update_post_meta($post_id, 'theme', $_POST['theme']);} 2 نقل قول لینک به ارسال
ARS 349 ارسال شده در اردیبهشت 92 مالک گزارش بازنشر ارسال شده در اردیبهشت 92 با کدهای قبلی ترکیب کنیدfunction save_post_meta($post_id){update_post_meta($post_id, 'theme', $_POST['theme']);}اینجوری قرار دادم که بازم نشد:<?php add_action("admin_init", "admin_init_meta_"); add_action('save_post', 'save_post_meta'); function admin_init_meta_(){ add_meta_box("prodInfo-meta", "اطلاعات نمونه کار", "meta_options", "samples", "normal", "high"); } function meta_options(){ global $post; $theme= get_post_meta( $post->ID, 'theme', true ); $details= get_post_meta( $post->ID, 'details', true ); $works= get_post_meta( $post->ID, 'works', true ); $site= get_post_meta( $post->ID, 'site', true ); $more= get_post_meta( $post->ID, 'more', true );?> <table border="0"> <tr> <td><label>قالب</label></td><td><input type="text" name="theme" value="<?php echo $theme; ?>" size="40" /></td> </tr> <tr> <td><label>تکنولوژی</label></td><td><input type="text" name="details" value="<?php echo $details; ?>" size="40" /></td> </tr> <tr> <td><label>خدمات انجام شده</label></td><td><input type="text" name="works" value="<?php echo $works; ?>" size="40" /></td> </tr> <tr> <td><label>آدرس سایت</label></td><td><input type="text" name="site" value="<?php echo $site; ?>" size="40" /></td> </tr><tr> <td><label>اطلاعات بیشتر</label></td><td><input type="text" name="more" value="<?php echo $more; ?>" size="40" /></td> </tr> </table><?php }function save_post_meta($post_id){// Bail if we're doing an auto save if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; // if our nonce isn't there, or we can't verify it, bail if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return; // if our current user can't edit this post, bail if( !current_user_can( 'edit_post' ) ) return; // more code global $post;update_post_meta($post_id, 'theme', $_POST['theme']);update_post_meta($post_id, 'details', $_POST['details']);update_post_meta($post_id, 'works', $_POST['works']);update_post_meta($post_id, 'site', $_POST['site']);update_post_meta($post_id, 'more', $_POST['more']); $theme= get_post_meta( $post->ID, 'theme', true ); $details= get_post_meta( $post->ID, 'details', true ); $works= get_post_meta( $post->ID, 'works', true ); $site= get_post_meta( $post->ID, 'site', true ); $more= get_post_meta( $post->ID, 'more', true );}?>البته اینو یادم رفته بود بگم که برای پست سفارشی استفاده می کنم! نقل قول لینک به ارسال
Parsa 23463 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 add_action("admin_init", "admin_init_meta_");add_action('save_post', 'save_post_meta');function admin_init_meta_(){add_meta_box("prodInfo-meta", "اطلاعات نمونه کار", "meta_options", "page", "normal", "high");}function meta_options(){global $post;$theme= get_post_meta( $post->ID, 'theme', true );$details= get_post_meta( $post->ID, 'details', true );$works= get_post_meta( $post->ID, 'works', true );$site= get_post_meta( $post->ID, 'site', true );$more= get_post_meta( $post->ID, 'more', true );wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );?><table border="0"><tr><td><label>قالب</label></td><td><input type="text" name="theme" value="<?php echo $theme; ?>" size="40" /></td></tr><tr><td><label>تکنولوژی</label></td><td><input type="text" name="details" value="<?php echo $details; ?>" size="40" /></td></tr><tr><td><label>خدمات انجام شده</label></td><td><input type="text" name="works" value="<?php echo $works; ?>" size="40" /></td></tr><tr><td><label>آدرس سایت</label></td><td><input type="text" name="site" value="<?php echo $site; ?>" size="40" /></td></tr><tr><td><label>اطلاعات بیشتر</label></td><td><input type="text" name="more" value="<?php echo $more; ?>" size="40" /></td></tr></table><?php}function save_post_meta($post_id){// Bail if we're doing an auto saveif( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;// Secondly we need to check if the user intended to change this value.if ( ! isset( $_POST['myplugin_noncename'] ) || ! wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename( __FILE__ ) ) )return;// if our current user can't edit this post, bailif( !current_user_can( 'edit_post' ) ) return;// more codeupdate_post_meta($post_id, 'theme', $_POST['theme']);update_post_meta($post_id, 'details', $_POST['details']);update_post_meta($post_id, 'works', $_POST['works']);update_post_meta($post_id, 'site', $_POST['site']);update_post_meta($post_id, 'more', $_POST['more']);} 3 نقل قول لینک به ارسال
ARS 349 ارسال شده در اردیبهشت 92 مالک گزارش بازنشر ارسال شده در اردیبهشت 92 پارسا جان این کد رو جایگزین کردم متا باکس کلا دیگه نمایش داده نمیشه! نقل قول لینک به ارسال
Parsa 23463 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 کد تست شدهمشکلی نداره 1 نقل قول لینک به ارسال
ARS 349 ارسال شده در اردیبهشت 92 مالک گزارش بازنشر ارسال شده در اردیبهشت 92 کد تست شدهمشکلی ندارهپارسا جان شرمنده ها ولی دقیقا همین کد رو گذاشتم متا باکس حذف شد!الان این کل فانکشن قالب : <?php//'----------- feature Post ---------------'if ( function_exists( 'add_theme_support' ) ) {add_theme_support( 'post-thumbnails' );add_image_size( 'hd_thumb', 520, 150, true );}function hd_thumb_image(){if ( has_post_thumbnail() ) {the_post_thumbnail( 'hd_thumb', array('class' => 'post-box-img') );};}//'----------- Samples ---------------'add_action('init', 'register_samples_cpt' );function register_samples_cpt() { $labels = array( 'name' => 'نمونه کار', 'singular_name' => 'نمونه کار', 'add_new' => 'افزودن نمونه کار', 'add_new_item' => 'افزودن نمونه کار جديد', 'edit_item' => 'ويرايش نمونه کار', 'new_item' => 'نمونه کار جديد', 'view_item' => 'نمايش نمونه کار', 'search_items' => 'جستجوي نمونه کار', 'not_found' => 'مطلب نمونه کاري يافت نشد', 'not_found_in_trash' => 'نمونه کاري در زبالهدان يافت نشد', 'parent_item_colon' => 'نمونه کار', 'menu_name' => 'نمونه کار', ); $args = array( 'labels' => $labels,'label' => 'نمونه کار', 'hierarchical' => false, 'description' => 'نمونه کار', 'supports' => array( 'title', 'thumbnail', 'custom-fields', 'post-formats' ), //'page-attributes' 'taxonomies' => array( 'page-category' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true,'menu_position' => 7, 'menu_icon' => get_template_directory_uri() . "/images/slogo.png", 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => true, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => array('slug' => 'samples'),'_builtin' => false, 'capability_type' => 'post' ); register_post_type( 'samples', $args );}function codex_samples_updated_messages( $messages ) {global $post, $post_ID;$messages['samples'] = array( 0 => '', // Unused. Messages start at index 1. 1 => sprintf( 'بخش نمونه کار بروز شد. <a href="%s">نمایش نمونه کار</a>', esc_url( get_permalink($post_ID) ) ), 2 => 'زمینه دلخواه نمونه کار بروز شد', 3 => 'زمینه دلخواه نمونه کار حذف شد', 4 => 'نمونه کار بروز شد', 5 => isset($_GET['revision']) ? sprintf( 'نمونه کار بازگردانی شد از تغییر %s', wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => sprintf( 'نمونه کار منتشر شد. <a href="%s">نمایش نمونه کار</a>', esc_url( get_permalink($post_ID) ) ), 7 => 'نمونه کار ذخیره شد.', 8 => sprintf( 'نمونه کار ارسال شد. <a target="_blank" href="%s">پیش نمایش نمونه کار</a>', esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 9 => sprintf( 'نمونه کار برنامهریزی شده برای: <strong>%1$s</strong>. <a target="_blank" href="%2$s">پیش نمایش نمونه کار</a>', date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 10 => sprintf( __('پیشنویس نمونه کار بروز شد. <a target="_blank" href="%s">پیش نمایش نمونه کار</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),);return $messages;}add_filter( 'post_updated_messages', 'codex_samples_updated_messages' );?><?phpadd_action("admin_init", "admin_init_meta_");add_action('save_post', 'save_post_meta');function admin_init_meta_(){add_meta_box("prodInfo-meta", "اطلاعات نمونه کار", "meta_options", "page", "normal", "high");}function meta_options(){global $post;$theme= get_post_meta( $post->ID, 'theme', true );$details= get_post_meta( $post->ID, 'details', true );$works= get_post_meta( $post->ID, 'works', true );$site= get_post_meta( $post->ID, 'site', true );$more= get_post_meta( $post->ID, 'more', true );wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );?><table border="0"><tr><td><label>قالب</label></td><td><input type="text" name="theme" value="<?php echo $theme; ?>" size="40" /></td></tr><tr><td><label>تکنولوژی</label></td><td><input type="text" name="details" value="<?php echo $details; ?>" size="40" /></td></tr><tr><td><label>خدمات انجام شده</label></td><td><input type="text" name="works" value="<?php echo $works; ?>" size="40" /></td></tr><tr><td><label>آدرس سایت</label></td><td><input type="text" name="site" value="<?php echo $site; ?>" size="40" /></td></tr><tr><td><label>اطلاعات بیشتر</label></td><td><input type="text" name="more" value="<?php echo $more; ?>" size="40" /></td></tr></table><?php}function save_post_meta($post_id){// Bail if we're doing an auto saveif( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;// Secondly we need to check if the user intended to change this value.if ( ! isset( $_POST['myplugin_noncename'] ) || ! wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename( __FILE__ ) ) )return;// if our current user can't edit this post, bailif( !current_user_can( 'edit_post' ) ) return;// more codeupdate_post_meta($post_id, 'theme', $_POST['theme']);update_post_meta($post_id, 'details', $_POST['details']);update_post_meta($post_id, 'works', $_POST['works']);update_post_meta($post_id, 'site', $_POST['site']);update_post_meta($post_id, 'more', $_POST['more']);}?><?php// Widgetsif ( function_exists( 'register_sidebar' ) ) {register_sidebar(array('name' => 'Sidebar','id' => 'sidebar','before_widget' => '<li id="%1$s" class="boxed widget %2$s">','after_widget' => '</li>','before_title' => '<h3 class="widgettitle">','after_title' => '</h3>'));register_sidebar(array('name' => 'Footer Left','id' => 'footer_left','before_widget' => '<li id="%1$s" class="widget %2$s">','after_widget' => '</li>','before_title' => '<h3 class="widgettitle">','after_title' => '</h3>'));register_sidebar(array('name' => 'Footer Middle','id' => 'footer_middle','before_widget' => '<li id="%1$s" class="widget %2$s">','after_widget' => '</li>','before_title' => '<h3 class="widgettitle">','after_title' => '</h3>'));register_sidebar(array('name' => 'Footer Right','id' => 'footer_right','before_widget' => '<li id="%1$s" class="widget %2$s">','after_widget' => '</li>','before_title' => '<h3 class="widgettitle">','after_title' => '</h3>'));register_sidebar(array('name' => 'Header','id' => 'header','before_widget' => '<div id="headerbanner" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3 class="widgettitle">','after_title' => '</h3>'));}// Commentsfunction motiontheme_comment($comment, $args, $depth) {$GLOBALS['comment'] = $comment; ?><li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><div id="comment-<?php comment_ID(); ?>" class="comment-wrap"><?php echo get_avatar($comment,$size='50'); ?><div class="commentbody"><div class="author"><?php comment_author_link(); ?></div><?php if ( $comment->comment_approved == '0' ) : ?><em>(Your comment is awaiting moderation...)</em><?php endif; ?><div class="commentmetadata"><a href="#comment-<?php comment_ID(); ?>" title=""><?php comment_date('F jS, Y'); ?> at <?php comment_time(); ?></a> <?php edit_comment_link( 'edit', ' ' , '' ); ?></div><?php comment_text(); ?></div><!-- /commentbody --><div class="reply"><?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></div></div><!-- /comment --><?php}function motiontheme_ping($comment, $args, $depth) {$GLOBALS['comment'] = $comment; ?><li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"><div id="comment-<?php comment_ID(); ?>" class="comment-wrap"><div class="commentbody"><div class="author"><?php comment_author_link(); ?></div><?php if ( $comment->comment_approved == '0' ) : ?><em>(Your comment is awaiting moderation...)</em><?php endif; ?><?php comment_text(); ?></div><!-- /commentbody --></div><?php}// Load admin options pagerequire_once( get_template_directory() . '/functions/options-page.php' );$themecolors = array('bg' => '002728','border' => '021013','text' => 'ffffff','link' => 'a8ef9d','url' => 'a8ef9d');$content_width = 640;// Custom header imagedefine( 'HEADER_TEXTCOLOR', '' );define( 'HEADER_IMAGE', '%s/images/genericlogo.png' );define( 'HEADER_IMAGE_WIDTH', 236 );define( 'HEADER_IMAGE_HEIGHT', 62 );define( 'NO_HEADER_TEXT', true );function admin_header_style() {?><style type="text/css">#headimg {background-color: #005760;background-position: 50% 50%;background-repeat: no-repeat;height: <?php echo HEADER_IMAGE_HEIGHT;?>px;width: <?php echo HEADER_IMAGE_WIDTH;?>px;padding: 25px;}#headimg h1, #headimg #desc {display: none;}</style><?php }add_custom_image_header( '', 'admin_header_style' );// Theme options: hide categories, hide home linkfunction motion_hide_categories() {return get_option( 'motion_hide_categories' );}function motion_hide_homelink() {return get_option( 'motion_hide_homelink' );}?> شاید مشکل از جای دیگست؟؟!!! نقل قول لینک به ارسال
Morteza 34190 ارسال شده در اردیبهشت 92 گزارش بازنشر ارسال شده در اردیبهشت 92 اینطوری نمیشه راحت مشکل روپیدا کرد.با پوسته پیش فرض تست بگیرید ببییند متاباکس ها میان؟ 1 نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .