I have a "report" Custom Post Type registered in this way:

        'label' => 'Reports',
        'description' => '',
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => array('slug' => ''),
        'query_var' => true,
        'exclude_from_search' => false,
        'supports' => array('custom-fields','comments','author',),

As you can see, my report does not support title, but only custom-fields, comments, and author:

'supports' => array('custom-fields','comments','author',)

Hovewer, since the permalink of a post normally is something like:


now I always get something like:


I suppose that "auto-draft" is the title that is given by default to my report. I have no idea how to give a reasonable permalink. I would like to give one based on the custom-fields.

1 Answer 1

I have no idea how to give a reasonable permalink.

Give it a title. You don't have to use the title for anything but the permalink, and it will be used in the page title as well most likely but since it is already exposed in the permalink I don't see the harm. You never have to print it anywhere else if you don't want to. Not to be ornery, but that is the obvious solution and then everything more or less falls into place.

'title' is not something you can easily opt out of. How do you identify the reports on the "edit" screen for example? Those should probably all say "auto-draft" too, right? Or something pretty close? The page title-- on this page it looks like "plugin development - Give a permalink to ..."-- is usually set to the post title or derived from it. That bit shows up in most search engine results so you really need a decent title there if this is going to be exposed to the public. If you weren't looking to have the permalinks it would be different. You'd need to write your own interface to view the reports but at least some of the problems would not occur.

If you really want to, you could probably set the slug manually by hooking into the save_post filter and that might get a decent permalink. I don't think it will help with the admin screen though or with the page title. You should also be able use the slug the slug in the admin edit panel, but that is more code to write.

Please reconsider your decision not to use the title. That decision is costing you a fair bit of work, and I can't see the benefit.

  • Thank you. Very convincing. Just a question: in the admin page, can I rename "insert title here" in something other? I know it's a "title", but I would prefer if the other authors use a more fitting name.
    – User
    Dec 12, 2012 at 16:24
  • 1
    I'd consider that a new question but there is a enter_title_here filter that looks to be designed to do just what you are asking. Look in wp-admin/edit-form-advanced.php.
    – s_ha_dum
    Dec 12, 2012 at 16:34

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.