espensl
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: custom post type – permalink = 404Here is the code that sets up the CPT and adds the “parent_id” field meta box.
function create_post_type(){ $labels = array( 'name' => _x('Creditors','post type general name'), 'singular_name' => _x('Creditor', 'post type singular name'), 'add_new' => _x('Add New', 'creditor'), 'add_new_item' => __('Add New Creditor'), 'edit_item' => __('Edit Creditor'), 'new_item' => __('New Creditor'), 'all_items' => __('All Creditors'), 'view_item' => __('View Creditor'), 'menu_name' => __('Creditors'), 'parent_item_colon' => '' ); $args = array( 'public' => true, 'hierarchical' => true, 'labels' => $labels, 'rewrite' => array('slug' => 'tilbydere'), 'has_archive' => true ); register_post_type('creditor', $args); } function creditor_custom_parent_setup(){ global $post; $post_type_object = get_post_type_object($post->post_type); if ( $post_type_object->hierarchical ) { $pages = wp_dropdown_pages(array( 'post_type' => 'page', 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column'=> 'menu_order, post_title', 'echo' => 0) ); if ( !empty($pages) ) { echo $pages; echo '<input type="hidden" name="parent_id_noncename" value="' . wp_create_nonce(__FILE__) . '" />'; } // end empty pages check } }Forum: Fixing WordPress
In reply to: Strange problem with Custom FieldsAh thank you very much! Worked like a charm 🙂
Viewing 2 replies - 1 through 2 (of 2 total)