• Resolved Rhand

    (@rhand)


    I am using Thematic WP Framework. I added a custom post type to the child theme functions.php based on https://kovshenin.com/archives/custom-post-types-in-wordpress-3-0/ :

    <?php
    // Fire this during init
    register_post_type('resort', array(
    	'label' => __('Resorts'),
    	'singular_label' => __('Resort'),
    	'public' => true,
    	'show_ui' => true,
    	'capability_type' => 'post',
    	'hierarchical' => false,
    	'rewrite' => false,
    	'query_var' => false,
    	'supports' => array('title', 'editor', 'author')
    ));
    
    add_action("manage_posts_custom_column", "my_custom_columns");
    add_filter("manage_edit-resort_columns", "my_resort_columns");
    
    function my_resort_columns($columns)
    {
    	$columns = array(
    		"cb" => "<input type=\"checkbox\" />",
    		"title" => "Resort Title",
    		"description" => "Description",
    		"length" => "Length",
    		"speakers" => "Speakers",
    		"comments" => 'Comments'
    	);
    	return $columns;
    }
    
    function my_custom_columns($column)
    {
    	global $post;
    	if ("ID" == $column) echo $post->ID;
    	elseif ("description" == $column) echo $post->post_content;
    	elseif ("length" == $column) echo "63:50";
    	elseif ("speakers" == $column) echo "Joel Spolsky";
    }
    
    ?>

    But this custom post type is not chown in the backend? What am I missing. i thought data added to child functions.php would be added to the mother functions.php ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Rhand

    (@rhand)

    Well I added the data to the main functions file and that does show up in the admin interface.

    add_action('init', 'portfolio_register');
     		flush_rewrite_rules();
    
    function portfolio_register() {
    
    	$labels = array(
    		'name' => _x('My Portfolio', 'post type general name'),
    		'singular_name' => _x('Portfolio Item', 'post type singular name'),
    		'add_new' => _x('Add New', 'portfolio item'),
    		'add_new_item' => __('Add New Portfolio Item'),
    		'edit_item' => __('Edit Portfolio Item'),
    		'new_item' => __('New Portfolio Item'),
    		'view_item' => __('View Portfolio Item'),
    		'search_items' => __('Search Portfolio'),
    		'not_found' =>  __('Nothing found'),
    		'not_found_in_trash' => __('Nothing found in Trash'),
    		'parent_item_colon' => ''
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => null,
    		'supports' => array('title','editor','thumbnail')
    	  ); 
    
    	register_post_type( 'portfolio' , $args );
    }

    Just keep on getting 404s going to these custom post types all of the sudden. Re-saving permalinks or using flush_rewrite_rules(); does not seem to work.

    Thread Starter Rhand

    (@rhand)

    Well, after re-saving permalinks and custom post type article in question the 404s disappeared. Using this code now to register a custom post type and custom taxonomy:

    add_action('init', 'destinations_register');
    
    function destinations_register() {
    
    	$labels = array(
    		'name' => _x('Destinations', 'post type general name'),
    		'singular_name' => _x('Individual Destination', 'post type singular name'),
    		'add_new' => _x('Add New', 'individual destination'),
    		'add_new_item' => __('Add New Destination'),
    		'edit_item' => __('Edit Individual Destination'),
    		'new_item' => __('New Destination'),
    		'view_item' => __('View Portfolio Item'),
    		'search_items' => __('Search Destinations'),
    		'not_found' =>  __('Nothing found'),
    		'not_found_in_trash' => __('Nothing found in Trash'),
    		'parent_item_colon' => ''
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true,
    		'query_var' => true,
    		'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
    		'rewrite' => true,
    		'capability_type' => 'post',
    		'hierarchical' => false,
    		'menu_position' => null,
    		'supports' => array('title','editor','thumbnail')
    	  ); 
    
    	register_post_type( 'destination' , $args );
    }
    
    register_taxonomy("Resorts", array("destination"), array("hierarchical" => true, "label" => "Resorts", "singular_label" => "Skill", "rewrite" => true));

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom post type in child theme’ is closed to new replies.