带有元框字段的自定义文章类型
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了带有元框字段的自定义文章类型相关的知识,希望对你有一定的参考价值。
Does not work at the moment. So don't copy it.
<?php add_action('init', function() use($name, $args) { 'public'=> true, 'label' => "All $upper" . 's', 'support' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields'), ), $args ); register_post_type('$name', $args); }); } //now we create and register a taxonomy add_action('init', function() use($name, $post_type, $args) { ), $args ); register_taxonomy($name, $post_type, $args); }); } /************************************************************ Now we add the names of the custom post type and taxonomies *************************************************************/ 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields'), )); add_taxonomy('language', 'snippet'); /************************************************************ Creating Metaboxes *************************************************************/ add_action('add_meta_boxes', function() { add_meta_box( 'er_snippet_info', 'Snippet Info', 'er_snippet_info_cb', 'snippet', 'normal', 'high' ); }); function er_snippet_info_cb() { global $post; $url = get_post_custom($post->ID); ?> <label for="er_associated_url">Associated URL: </label> <input type="text" name="er_associated_url" id="er_associated_url" value="<?php echo $url; ?>" /> <?php } add_action('save_post', function () { global $post; //security check if ($_POST && !wp_verify_nonce($_POST['er_nonce'], _FILE_)) { update_post_meta($post->ID, 'er_associated_url', $_POST['er_associated_url']); } } }); ?>
以上是关于带有元框字段的自定义文章类型的主要内容,如果未能解决你的问题,请参考以下文章
Wordpress - 特色图像元框未显示在自定义帖子类型上