admin管理员组

文章数量:1122846

I'm creating a new custom post type. But I need to limit the max length for the title. This is how I'm creating the field in my code:

array(
    'key' => 'title',
    'label' => 'Title',
    'name' => 'title',
    'type' => 'text',
    'required' => 1,
    'maxlength' => 65,
)

But the maxlength property isn't working. Is there a way to set this limit from code (not using a plugin) and only for this post type?

I'm creating a new custom post type. But I need to limit the max length for the title. This is how I'm creating the field in my code:

array(
    'key' => 'title',
    'label' => 'Title',
    'name' => 'title',
    'type' => 'text',
    'required' => 1,
    'maxlength' => 65,
)

But the maxlength property isn't working. Is there a way to set this limit from code (not using a plugin) and only for this post type?

Share Improve this question asked Mar 4, 2021 at 14:20 Santiago Mendoza RamirezSantiago Mendoza Ramirez 1113 bronze badges 1
  • Just build your CPT as you normally would then apply the following filter to it afterwards: wordpress.org/support/topic/… – Tony Djukic Commented Mar 5, 2021 at 17:19
Add a comment  | 

1 Answer 1

Reset to default 0
array(
    'key' => 'custom_post_title',
    'label' => 'Title',
    'name' => 'title',
    'type' => 'text',
    'required_over' => 1,
    'maxlength_set' => 65,
)

本文标签: Set a maxlength for the title input in a custom post type