• Gelöst juicylung

    (@juicylung)


    Hi Leute,

    ich versuche gerade mich mehr in die Materie Custom Post Type und Meta Box einzuarbeiten. Hierzu versuche ich ein kleines Rezept Plugin zu erstellen. Mir ist bewusst dass es da draußen welche gibt…

    Zum Problem: Das Plugin wird zwar erkannt, die Meta Box die ich mit einem action Hook und einer Funktion eingefügt habe, wird jedoch bisher nicht angezeigt.

    Mache ich was falsch? Oder kann die MetaBox an dieser Stellle gar nicht eingefügt werden? Hier ist mal mein bisheriger Code.

    <?php
    /*
    Plugin Name: WP Foodvana Recipe
    Plugin URI: http://www.juicy-arts.de
    Description: Add recipes to your posts. 
    Version: 1.0
    Author: Juicy Arts
    Author URI: http://www.juicy-arts.de
    Text Domain: wp-foodvana
    Domain Path: wp-foodvana
    */
    
    // Register Custom Post Type
    function wp_foodvana_recipe_post_type() {
    
    	$labels = array(
    		'name'                  => _x( 'WP Foodvana Recipes', 'Post Type General Name', 'wp-foodvana' ),
    		'singular_name'         => _x( 'WP Foodvana Recipe', 'Post Type Singular Name', 'wp-foodvana' ),
    		'menu_name'             => __( 'Foodvana', 'wp-foodvana' ),
    		'name_admin_bar'        => __( 'Foodvana Recipes', 'wp-foodvana' ),
    		'archives'              => __( 'Recipe Archives', 'wp-foodvana' ),
    		'attributes'            => __( 'Recipe Attributes', 'wp-foodvana' ),
    		'parent_item_colon'     => __( 'Parent Recipe:', 'wp-foodvana' ),
    		'all_items'             => __( 'All Recipes', 'wp-foodvana' ),
    		'add_new_item'          => __( 'Add New Item', 'wp-foodvana' ),
    		'add_new'               => __( 'Add New Recipe', 'wp-foodvana' ),
    		'new_item'              => __( 'New Item', 'wp-foodvana' ),
    		'edit_item'             => __( 'Edit Item', 'wp-foodvana' ),
    		'update_item'           => __( 'Update Item', 'wp-foodvana' ),
    		'view_item'             => __( 'View Item', 'wp-foodvana' ),
    		'view_items'            => __( 'View Items', 'wp-foodvana' ),
    		'search_items'          => __( 'Search Item', 'wp-foodvana' ),
    		'not_found'             => __( 'Not found', 'wp-foodvana' ),
    		'not_found_in_trash'    => __( 'Not found in Trash', 'wp-foodvana' ),
    		'featured_image'        => __( 'Featured Image', 'wp-foodvana' ),
    		'set_featured_image'    => __( 'Set featured image', 'wp-foodvana' ),
    		'remove_featured_image' => __( 'Remove featured image', 'wp-foodvana' ),
    		'use_featured_image'    => __( 'Use as featured image', 'wp-foodvana' ),
    		'insert_into_item'      => __( 'Insert into item', 'wp-foodvana' ),
    		'uploaded_to_this_item' => __( 'Uploaded to this item', 'wp-foodvana' ),
    		'items_list'            => __( 'Items list', 'wp-foodvana' ),
    		'items_list_navigation' => __( 'Items list navigation', 'wp-foodvana' ),
    		'filter_items_list'     => __( 'Filter items list', 'wp-foodvana' ),
    	);
    	$args = array(
    		'label'                 => __( 'WP Foodvana Recipe', 'wp-foodvana' ),
    		'description'           => __( 'Add recipes to your posts.', 'wp-foodvana' ),
    		'labels'                => $labels,
    		'supports'              => array( ),
    		'taxonomies'            => array( 'category', 'post_tag' ),
    		'hierarchical'          => false,
    		'public'                => true,
    		'show_ui'               => true,
    		'show_in_menu'          => true,
    		'menu_position'         => 5,
    		'show_in_admin_bar'     => true,
    		'show_in_nav_menus'     => true,
    		'can_export'            => true,
    		'has_archive'           => true,		
    		'exclude_from_search'   => false,
    		'publicly_queryable'    => true,
    		'capability_type'       => 'post',
    	);
    	register_post_type( 'wp_foodvana', $args );
    
    }
    add_action( 'init', 'wp_foodvana_recipe_post_type', 0 );
    
    add_action( 'add_meta_box', 'wp_foodvana_add_custom_meta_box' );
    
    function wp_foodvana_add_custom_meta_box() {
    add_meta_box(
    'Recipe Editor',
    __( 'WP Foodvana Recipe', 'wp-foodvana' ),
    'wp_foodvana_editor',
    'wp_foodvana',
    'normal',
    'high'
    );
    }
    function wp_foodvana_editor( $post ) {
    	
    echo "Test of the Meta Box";
    }
    
Ansicht von 3 Antworten – 1 bis 3 (von insgesamt 3)
Ansicht von 3 Antworten – 1 bis 3 (von insgesamt 3)
  • Das Thema „Custom Meta Box wird nicht angezeigt“ ist für neue Antworten geschlossen.