WordPress.org

Ready to get started?Download WordPress

Forums

Remove base slug on Custom Post Type? (5 posts)

  1. ryanve
    Member
    Posted 3 years ago #

    I know it's possible to customize the base slug when registering a CPT, but is it possible to completely remove the base?

    E.g. I want to make the url example.com/headline/ rather than example.com/slugname/headline/

    This didn't work:
    'rewrite' => array('slug' => '', 'with_front' => true, ),

  2. ryanve
    Member
    Posted 2 years ago #

    Whoa—this works:

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

    It removes the slug w/o adding extra slashes.

  3. Aurélien Denis
    Member
    Posted 2 years ago #

    Are you sure it works ? I'm using WordPress 3.2.1 and it just go back to default URL using "?"

  4. Anatta
    Member
    Posted 2 years ago #

    It works for me on using Network 3.2.1. Does anyone know how to add a slug to pages to rule out any chance of conflicts?

  5. ryanve
    Member
    Posted 2 years ago #

    When you want to add a slug to the CPT it's like this:

    'rewrite' => array('slug' => 'myslug')

    But for pages, I'm not sure (aside from making child pages).

    It seems slugless CPTs can cause errors. I don't recommend them. See thread.

Topic Closed

This topic has been closed to new replies.

About this Topic