views:

753

answers:

1

Hello all,

I am trying to achieve a custom URL structure with Wordpress. Basically, my site functions as my blog and my portfolio. I want to have an "Articles" section and a "Portfolio" section. I want the articles to display on the Articles page, and the portfolio on the Portfolio page. Should be easy, except on top of that I want custom URLs...

I want the URLs setup like this:

Articles page: http://mydomain.com/discusses

Specific article: http://mydomain.com/discussed/%postname%

Portfolio page: http://mydomain.com/does

Specific design: http://mydomain.com/designed/%postname%

I can figure out how to do only one rewrite of this type, but WP doesn't have built in functionality to do both. I'm just wondering where I should start or what I should do...

The problem also becomes, I want to retain category functionality in both areas, so maybe it needs to be achieved with Custom Fields? and add a new rewrite rule based on the custom field of a post? I have idea where to start...

Thanks for any help you can give.

+2  A: 

This actually isn't that hard to do. I'll go down, page by page, what you would need to do to achieve this.

Articles Page

Create a new template in your theme folder (/wp-content/themes/your-theme/) called discusses.php and just add the following content:

<?php
/*
Template Name: Discusses Template
*/
?>

You don't need any more content. Go into the Pages section of WordPress Admin and create a new page called Articles page and set the URL to be /discusses/. Set the template of this page to be Discusses Template. Now, go into the Settings → Reading section in Admin and set the Posts page to Articles page. Now all your blog posts will appear under the URL /discusses/

Specific Article

The easiest way to have all your articles appearing as /discussed/title is to rename the default category (in Posts → Categories) to discussed. Then set your permalinks to be:

/%category%/%postname%/

This will render the links you need for each post.

Portfolio Page & Specific Design Page

Assuming this will be some kind of custom design, the easiest thing to do would be to create a custom template and Page in the pages section, as you did for the articles page, and throw your custom HTML and CSS into that. I would then set each specific design page to be a child page of that in the pages section. You can use the WPdb classs to make custom queries to populate the Portfolio page.

pmckenna
Woah thank you for such an in depth response! The only problem is that I wanted to retain the category function, and also have the portfolio pieces be posts as well.But I think I have found the solution while continuing to search after posting this topics. Something called "custom taxonomies". I can create a category-like/tag-like container that I can use in the exact same way. I am going to have it called "type" and then have values for posts be either "article" or "portfolio". And then in each page, I can hopefully run a loop that gets all posts with those specific value for "type"
Ian Storm Taylor
Ran out of space above, but I wanted to say thanks again for such a detailed comment. Much appreciated!
Ian Storm Taylor