Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to create a new custom post type, but the issue i am having is that the name i want to give is longer than 20 characters.

Is it possible to override this with a hook or filter?

I tried to modify this file in wp-includes post.php on line 1237(strlen > 20), but this removed the publish button and replace it with Submit for review.

Any idea how i fix this matter.

tanks.

share|improve this question
1  
Do you absolutely have to use a custom post type name of more than 20 characters? What is your aim? –  RRikesh Jan 19 '13 at 16:27

1 Answer 1

You cannot change that value. The database schema is limited to 20 Bytes. See wp-admin/includes/schema.php:

TABLE $wpdb->posts (
  ID bigint(20) unsigned NOT NULL auto_increment,
  post_author bigint(20) unsigned NOT NULL default '0',
  post_date datetime NOT NULL default '0000-00-00 00:00:00',
  post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
  post_content longtext NOT NULL,
  post_title text NOT NULL,
  post_excerpt text NOT NULL,
  post_status varchar(20) NOT NULL default 'publish',
  comment_status varchar(20) NOT NULL default 'open',
  ping_status varchar(20) NOT NULL default 'open',
  post_password varchar(20) NOT NULL default '',
  post_name varchar(200) NOT NULL default '',
  to_ping text NOT NULL,
  pinged text NOT NULL,
  post_modified datetime NOT NULL default '0000-00-00 00:00:00',
  post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
  post_content_filtered longtext NOT NULL,
  post_parent bigint(20) unsigned NOT NULL default '0',
  guid varchar(255) NOT NULL default '',
  menu_order int(11) NOT NULL default '0',
  post_type varchar(20) NOT NULL default 'post',
  post_mime_type varchar(100) NOT NULL default '',
  comment_count bigint(20) NOT NULL default '0',
  PRIMARY KEY  (ID),
  KEY post_name (post_name),
  KEY type_status_date (post_type,post_status,post_date,ID),
  KEY post_parent (post_parent),
  KEY post_author (post_author)
)

If you need just longer slugs in your URLs you can do that in the argument rewrite:

register_post_type( 
    'yxz123', 
    array (
        'rewrite' => array (
            'slug'       => _x( 'really-long-slug', 'slug', 'custom_plugin_textdomain' ),
            'with_front' => FALSE
        ),
    ) 
);
share|improve this answer
    
thanks, i know it is not ideal, but i modified the table schema. Now everything seem to work fine. Do you think this will effect Wordpress anyway? –  TheDeveloper Jan 19 '13 at 15:02
    
I don’t know if that will have side effects. But be aware some updates might change the schema back. I will add an alternative to my answer. –  toscho Jan 19 '13 at 20:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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