0

I am creating my own posts in wordpress however I have hit a little problem and im not sure how to fix it.

The below register_post_type creates an Invalid post type error.

add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'talent',
    array(
        'labels' => array(
            'name' => __( 'Talent' ),
            'singular_name' => __( 'talent' )
        ),
    'public' => true,
    'has_archive' => true,
    )
);
}

it doesn't seem to like the word talent. If I change 'talent' to 'arist' it works. However it needs to be 'talent' for the URL. Ive checked on wordpress and using talent shouldn't cause any conflicts with default wordpress settings.

  • What happens when you use talent? – fuxia May 17 '14 at 9:40
  • creates an Invalid post type error. – user2648610 May 17 '14 at 9:41
  • Tested your code and it works for me. Do you have a plugin installed which creates cpt's? – Brad Dalton May 17 '14 at 9:43
  • No I have no plugins installed. Could it be because it started off as artist? Now im trying to change it? – user2648610 May 17 '14 at 9:44
  • 1
    You need to check if did not maybe by change registered your post type twice. Just a thought – Pieter Goosen May 17 '14 at 9:47
2

If you can't get the "talent" post type to register, set the name to artist and then using the Rewrite option for the CPT e.g.

'rewrite' => array( 'slug' => 'talent' ),

That will give you the URL you desire

4

I had the same issue but the answer did not work for me. In case anyone else finds this, make sure the post type title is not longer than 20 characters. That might be the issue and Wordpress will not care to let you know.

Credits go to: https://stackoverflow.com/a/26029803/722036

  • Very nice find, spent a lot of time this morning trying to figure out why in the world my post type wouldn't register. – Josh Foskett Mar 18 '16 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.