Custom Permalink for Custom Post Type

Discussion in 'WordPress' started by stephan2307, Aug 12, 2015.

  1. #1
    Got a small problem and wonder if someone can help me with this.

    So when we started building the current website, all posts where living in the root ie
    http://somedomain.com/post-slug-here

    Now we added a custom post type called discussions and the client decided that they would like the posts as http://somedomain.com/articles/post-slug-here and the discussions as http://somedomain.com/discussions/discussion-slug-here.

    So we set the permalinks to Custom Structure and set them to /articles/%postname%/.

    This works for articles but not for discussions. They appear as /articles/discussions/discussion-slug-here/.

    Does anyone know how to fix this?
     
    stephan2307, Aug 12, 2015 IP
  2. KangBroke

    KangBroke Notable Member

    Messages:
    1,026
    Likes Received:
    59
    Best Answers:
    4
    Trophy Points:
    265
    #2
    KangBroke, Aug 12, 2015 IP
  3. KangBroke

    KangBroke Notable Member

    Messages:
    1,026
    Likes Received:
    59
    Best Answers:
    4
    Trophy Points:
    265
    #3
    maybe try /%category%/%postname%/
     
    KangBroke, Aug 12, 2015 IP
  4. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #4
    That's correct. As soon as I remove the articles from the permalink structure the articles are again the the root.

    This will cause the url's to look like this
    http://somedomain.com/uncategorised/postname/
    http://somedomain.com/discussion/postname/

    So close but still not quite there.

    Anyone else got any ideas?
     
    stephan2307, Aug 12, 2015 IP
  5. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #5
    Right I managed to fix it.
    'rewrite' => array('slug' => 'discussion','with_front' => false),
    PHP:
    the with_front => false does the magic.

    and for the articles I set the permalink to /articles/%postname%/
     
    stephan2307, Aug 12, 2015 IP
  6. Keith Lock

    Keith Lock Greenhorn

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    I realize this may not help mid-production, but for anyone else, what I do... I use a free plugin [WP-Types] to create any custom post types, and during the process I have the ability to set the permalink structure (or, it defaults to the "slug" of the CPT anyways, so no need to go custom, but the option is still there). Then, the rest of the site remains as is. Hope this is helpful!
     
    Keith Lock, Aug 13, 2015 IP