Support » Fixing WordPress » WP Bug with Custom Types

  • Resolved driz


    I have my posts sectioned off by using a custom page and setting the permalinks to /news/%category%/%postname%/ which works great.

    The problem is when using custom post types, they inherit the /news/ part of the permalinks, which is incorrect as I have specified a permalink for the type in the functions file. Anyone else agree? Have a solution? Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Any thoughts on this?

    Chris Olbekson


    Level 12 Bug Squasher & Forum Moderator

    That is the way they are supposed to work. If your permalinks are set to /news/%category%/%postname%/ there is no way to remove the /news/ from any url on your site.

    So how do I get /news/%category%/%postname%/ for my news posts and /events/event-name/ for events post type?

    Chris Olbekson


    Level 12 Bug Squasher & Forum Moderator

    Change your permalink structure to: /%category%/%postname%/

    Give all your “news” posts a parent category named “news” then create child categories

    When you create the “events” custom post type set your labels array to include:

    'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => true,

    The whole point of WP 3.0 post types was to get away from having to use categories to section off content like this and use them solely for organizing them like they built for.

    I don’t get the /news/ part on my pages, so why on my post types? When I have given it a unique permalink. Defo a crappy way of workings in WP!

    The solution above isn’t going to work as I want to have URL’s like /news/2010/20/post-name/ or /news/category/system-updates/

    Set with_front to false in the rewrite arg (defaults to true/enabled).


    'rewrite' => array( 'slug' => 'your_post_type_slug', 'with_front' => false )

    And the URLs will work as you’re expecting..

    Code is tested using your permalink settings and a custom post type, works for me… 😉

    NOTE: You may possibly need to click save on the permalink page after making the necessary code change.

    Phew. Glad someone on the WP dev team had thought of this. Thanks t31os_

    You’re welcome.. 🙂

    Very easy to replicate so i was pretty confident there’d be a way to fix it.. if not i’d have logged it as a bug (turns out there was no need though).

    Chris Olbekson


    Level 12 Bug Squasher & Forum Moderator

    Good catch t31os_,

    I thought the with_front defaulted to false. There are a few threads with this same problem and nobody could get it to work. I will try and reference them here.

    All i did was read the docs, and i don’t mean that in a condescending way.

    You could be right c3mdigital, the functionality might have changed, i don’t know for sure, but it’s certainly possible the default was previously false.

    Happy to help all the same.. 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘WP Bug with Custom Types’ is closed to new replies.