Results 1 to 8 of 8

Thread: problem with custom post type since 3.0.1

  1. #1
    slee is offline Here For The Peanuts
    Join Date
    Apr 2010
    Location
    UK
    Posts
    106

    Default problem with custom post type since 3.0.1

    Since upgrading to the latest WordPress release (3.0.1) the custom post type i set up is not working quite as it should.

    here is the code i use:

    Code:
     register_post_type('tfh_campaigns', 
    	array(
    	'label' => __('Campaigns'),
    	'singular_label' => __('Campaign'),
    	'public' => true,
    	'show_ui' => true,
    	'capability_type' => 'post',
    	'hierarchical' => false,
    	'rewrite' => array('slug' => 'campaigns', 'with_front' => false ),
    	'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail'),
    	'menu_position' => NULL,
    	'can_export' => true,
    
    ));
    In the admin there is a new section called campaigns and i can add new etc.
    When I click add new it takes me to a page with Add New Post which before it would say Add New Campaign so what could be wrong?
    Also although I have set it to have a featured image the box does not show.

    I do have:

    Code:
    if (function_exists('add_theme_support')) {
    	add_theme_support('post-thumbnails', array( 'post', 'page' ) );
    	set_post_thumbnail_size(120, 90, true);
    	add_image_size('news-image', 260, 999);
    }
    to add the ability to use the featured image which works fine if i go to posts but using the custom post type it no longer works.

    Since 3.0.1 has something changed am i doing something wrong?

  2. #2
    slee is offline Here For The Peanuts
    Join Date
    Apr 2010
    Location
    UK
    Posts
    106

    Default

    Managed to figure it out although it is a bit odd.

    To have the image for custom post types I had to use:

    Code:
    add_theme_support( 'post-thumbnails' );
    using:

    Code:
    add_theme_support('post-thumbnails', array( 'post', 'page' ) );
    for some reason does not work for custom pot types anymore so maybe there is another item that we can add into the allowed items?

    The code to add labels has now also been updated so i will have to set more items in the array list like this portfolio one i found:

    Code:
    $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 );
    Bit odd how it was all working in 3.0 but in 3.0.1 it stopped working

  3. #3
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,797

    Default

    I assume you need to add that post-type to the 'post' and 'page' options:
    Code:
    add_theme_support('post-thumbnails', array( 'post', 'page' ) );
    I assume that is a bug fix as it seems odd that post thumbnails would have worked on something which was only set for the 'post' and 'page' post-types and not your custom post-type.

  4. #4
    slee is offline Here For The Peanuts
    Join Date
    Apr 2010
    Location
    UK
    Posts
    106

    Default

    I guess it is a bug fix but then shouldnt there be a way of specifically adding it to custom post types? eg:

    Code:
    add_theme_support('post-thumbnails', array( 'post', 'page','custom-post-type' ) );
    as now the feature image shows up on everything and I don't want it to be on pages.

  5. #5
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,797

    Default

    Quote Originally Posted by slee View Post
    I guess it is a bug fix but then shouldnt there be a way of specifically adding it to custom post types? eg:

    Code:
    add_theme_support('post-thumbnails', array( 'post', 'page','custom-post-type' ) );
    as now the feature image shows up on everything and I don't want it to be on pages.
    Does the following work?
    Code:
    add_theme_support('post-thumbnails', array( 'custom-post-type' ) );
    If not, then that looks like a bug as I'd have expected that to work just fine.

  6. #6
    slee is offline Here For The Peanuts
    Join Date
    Apr 2010
    Location
    UK
    Posts
    106

    Default

    good news doing:
    Code:
    add_theme_support('post-thumbnails', array( 'post', 'page','custom-post-type' ) )
    works fine, my first attempt i accidentally left a space in the name.

  7. #7
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,797

    Default

    Quote Originally Posted by slee View Post
    good news doing:
    Code:
    add_theme_support('post-thumbnails', array( 'post', 'page','custom-post-type' ) )
    works fine, my first attempt i accidentally left a space in the name.
    Did my suggestion not work?

  8. #8
    slee is offline Here For The Peanuts
    Join Date
    Apr 2010
    Location
    UK
    Posts
    106

    Default

    yes removing pst and page and just having the custom post type name works fine or in a any form ie post and custom post type stop them working for pages which is perfect. Hopefully they will document this soon and give plugin devs a way to use it without interfering with theme code as well. for now ill use a hook to fire it at a convenient time

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •