我对插件开发相当陌生,但在编码方面有经验。我已经阅读了一些教程,并设法将我的帖子类型设置为幻灯片,但我想添加一个元框来放置URL。
然而,它并没有显示出来,我跟随的许多教程都说我现在应该看到它了。有人能帮忙吗?下面的教程、代码和图片链接。
后续教程:https://www.sitepoint.com/real-world-example-wordpress-plugin-development/
我也尝试过其他教程(来自:themefoundation and code.tutsplus),但它们似乎都不能与我已经编写的内容配合使用
(文本为荷兰语抱歉)
<?php
function register_slide_content_type(){
$labels = array(
\'name\' => _x( \'Slides\', \'slideshow\' ),
\'singular_name\' => _x( \'Slides\', \'slideshow\' ),
\'add_new\' => _x( \'Nieuwe Slide\', \'slideshow\' ),
\'add_new_item\' => _x( \'Nieuwe Slide Toevoegen\', \'slideshow\' ),
\'edit_item\' => _x( \'Edit Slide\', \'slideshow\' ),
\'new_item\' => _x( \'Nieuwe Slide\', \'slideshow\' ),
\'view_item\' => _x( \'Bekijk Slide\', \'slideshow\' ),
\'search_items\' => _x( \'Zoek Slides\', \'slideshow\' ),
\'not_found\' => _x( \'Geen slides gevonden\', \'slideshow\' ),
\'not_found_in_trash\' => _x( \'Geen slides gevonden in prullenbak\', \'slideshow\' ),
\'parent_item_colon\' => _x( \'Parent Slide:\', \'slideshow\' ),
\'menu_name\' => _x( \'Slideshow\', \'slideshow\' ),
);
//arguments for post type
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'description\' => \'Slides voor op de website\',
\'taxonomies\' => array( \'plaatsen\' ),
\'public\' => true,
\'publicly_queryable\'=> true,
\'show_ui\' => true,
\'show_in_nav\' => true,
\'query_var\' => true,
\'supports\' => array(\'title\',\'thumbnail\',\'editor\'),
\'has_archive\' => true,
\'menu_position\' => 5,
\'show_in_admin_bar\' => true,
\'menu_icon\' => \'dashicons-images-alt2\',
\'rewrite\' => array(\'slug\' => \'slides\', \'with_front\' => \'true\')
);
register_post_type( \'slideshow\', $args );
}
add_action( \'init\', \'register_slide_content_type\' );
function plaatsen_taxonomy() {
register_taxonomy(
\'plaatsen\',
\'slideshow\',
array(
\'hierarchical\' => true,
\'label\' => \'Plaatsingen\',
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => \'plaatsen\',
\'with_front\' => false
)
)
);
}
add_action( \'init\', \'plaatsen_taxonomy\');
add_action( \'load-post.php\', \'slide_post_meta_boxes_setup\' );
add_action( \'load-post-new.php\', \'slide_post_meta_boxes_setup\' );
function slide_post_meta_boxes_setup() {
add_action( \'add_meta_boxes\', \'slide_add_post_meta_boxes\' );
}
function slide_add_post_meta_boxes() {
add_meta_box(
\'pukkemukslideshow\', // Unique ID
__( \'Slideshow\', \'example\' ), // Title
\'slide_post_class_meta_box\', // Callback function
\'post_type\', // Admin page (or post type)
\'advanced\', // Context
\'high\' // Priority
);
}
function slide_post_class_meta_box( $post ) { ?>
<p>
<label for="slide-post-class">Plak hier de URL waar de slide naar moet wijzen.</label>
<br />
<input type="text" name="slide-post-class" id="slide-post-class" value="<?php echo esc_attr( get_post_meta( $post->ID, \'slide_post_class\', true ) ); ?>" size="30" />
</p>
<?php }
?>