I wonder what’s the right way of creating portfolio website (with as many portfolio pages I want). Usually I create page template that displays posts with category = Portfolio
or with posts from Portfolio Custom Post Type. But what if I want multiple portfolios on my site? I know I can do it for example thru Theme Options page by assigning category to every portfolio page, but maybe there is a better way?
Can I build mechanism like that:
- I add page and choose “Portfolio” template.
- After choosing template custom meta box appears. Inside custom box I have list of categories from my Portfolio Custom Post Type and I can choose which of the categories are displayed in this portfolio.
I think the best, most WordPress friendly solution is to use the default template hierarchy.
If you’re using a custom post type and default categories, you first need to get the post type into the category (and tag) archive pages. This support thread does that.
Now, you can see the portfolio items at yoursite.com/category/web-design, where “category” is the base category slug set on Settings > Permalinks and “web-design” would be the slug of a category denoting a specific portfolio.
If you’re using a custom taxonomy, you can control the slug better and have something like yoursite.com/portfolios/web-design. (Note that “portfolios” is plural. Make sure it doesn’t overlap with an existing slug on your site.)
Finally, to customize the results, you use the template hierarchy. If you’re using categories, then you can either edit all category pages with
category.php
(or create it based onarchive.php
) orcreate category-web-design.php
(to edit a specific category template). If you’re using a custom taxonomy, use the filetaxonomy-portfolios.php
for the whole custom taxonomy ortaxonomy-portfolios-web-design.php
for the specific term.This is how WordPress is designed to be used, so I can’t think of a better, more manageable way to handle this.