Wsparcie » Wtyczki » Custom post type

  • Storzyłem custom post type o nazwie Stojany. Jest widoczne w Panelu administracyjny. Mogę dodawać kolejne pozycje. Chaciałbym teraz aby klikajac w menu na stronie wylistowac wszystkie wpisy tam dodane. Możecie podpowiedzieć gdzie i jaki kod dodac ? Poniżej to co mam w function.php

    add_action('init', 'note_register');
    
    function note_register() {
        $args = array(
            'label' => __('Stojany'),
            'singular_label' => __('Stojan'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'supports' => array('title')
        );
        register_post_type( 'note' , $args );
    }
    
    add_action("admin_init", "add_note_info");
    
    function add_note_info() {
        add_meta_box("noteInfo-meta",  __( 'Stojany informacje') , "meta_options", "note", "normal", "low");
    }
    
    function meta_options() {
        global $post;
    
        $custom = get_post_custom($post->ID);
    
        $note_content = $custom["note_content"][0];?>
        <label style="display: block; margin-bottom: 5px"> <?php _e( 'Enter note content:') ?> </label><textarea cols="20" rows="5" name="note_content" style="width:99%"><?php echo esc_attr( $note_content ); ?> </textarea>'
    
        <?php $ref_post = $custom["ref_post"][0]; ?>
        <label><?php _e( 'Enter reference post title:') ?></label><input type="text" name="ref_post" value="<?php echo esc_attr( $ref_post ); ?>" size="80" style="width:97% />
    
    <?php }
    
    add_action('save_post', 'save_note_data');
    
    function save_note_data() {
        global $post;
    
        update_post_meta($post->ID, "note_content", $_POST["note_content"]);
        update_post_meta($post->ID, "ref_post", $_POST["ref_post"]);
    }
    
    add_filter("manage_edit-note_columns", "note_edit_columns");
    
    function note_edit_columns($columns) {
        $columns = array(
            "cb" => "<input type=\"checkbox\" />",
            "title" => __('Note title'),
            "note_content" => __('Description'),
            "ref_post" => __('Reference post'),
            'date' => __('Note date'),
        );
        return $columns;
    }
    
    add_action("manage_posts_custom_column",  "note_custom_columns");
    
    function note_custom_columns($column) {
        global $post;
        switch ($column) {
            case "note_content":
                $custom = get_post_custom();
                echo $custom["note_content"][0];
                break;
            case "ref_post":
                $custom = get_post_custom();
                echo $custom["ref_post"][0];
                break;
        }
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom post type’ is closed to new replies.