Search code examples
wordpressparent

Blog items and portfolio items with a different parent


i'm stuck in trying to solve this problem. I'm editing a premade theme and i'm trying to get the following:

for portfolio item > www.mysite.com/portfolio/item

for blog item > www.mysite.com/blog/item

The problem is that if i edit the "permalinks" adding /blog/ in the custom entries i'll get the following:

for portfolio item > www.mysite.com/blog/portfolio/item

for blog item > www.mysite.com/blog/item

How can i solve this problem?


Solution

  • When you setup your portfolio post type, you'll want to set it's 'with_front' parameter to false:

    $args = array(
      //Other arguments would go here...
      'rewrite' => array( 'with_front' => false )
    )
    register_post_type('portfolio',$args);
    

    This should allow you to use '/blog' for all other posts, but will remove '/blog' from the URL of portfolio posts