Some StudioPress themes already include a portfolio page built into the child theme. Most use a custom post type however it can only be used to create one portfolio.
If you want more than one portfolio, then this tutorial is for you.
In this exercise, we’ll be duplicating the existing portfolio page used in the Minimum child theme.
Duplicating Existing Portfolio Page
Here’s a summary of the steps you’ll need to take:
- Copy & rename both archive-portfolio.php and single-portfolio.php files
- Copy & rename portfolio custom post type in functions.php file
- Copy & rename add new image size in functions.php file
- Copy & rename CSS code for portfolio classes in style.css file
You can either manually rename the code or use a text editor like Notepad++.
I used Notepad++ to search and find all code with the name ‘portfolio’ and replaced it using the name ‘second’.
Update: Here’s an easier way to convert category archive pages into portfolio style archive pages using the Balance child theme
Second Portfolio Archive Template
Here’s the code which needs to be pasted in a new PHP file named archive-second.php
Second Portfolio Single Template
Here’s the code which needs to be pasted in a new PHP file named single-second.php
Rename Portfolio Custom Post Type
This code also includes the new support for CPT archive pages included in Genesis 2.0
Second Portfolio Image Size
This code needs to be pasted in your child themes functions.php file.
Display Number Of Portfolio Items
Add this code in your child themes functions.php file to determine exactly how many items to display on your portfolio archives page.
Duplicate Second Portfolio CSS Code
Paste this code at the end of your child themes style.css file.
You could simply duplicate each CSS rule underneath the original rule and rename it using the second selector rather than paste all the code at the end of the file. This is the method i used to test it worked properly.
Themes Which Are 960px Wide
You will need to make changes to the CSS code if you want to use the code in this tutorial on a theme which is 960px wide.
Here’s the code you need to add to replace in your child themes style.css file.
Conclusion
I successfully completed the duplication of existing Portfolio custom post type without any problems however you may have to spend some time adjusting the CSS code for themes other than the Minimum theme.
This is what I want.. Now I become a big fan of your site.. Great tutorial..
Supat
From Thailand
Hi, I’d love to change the URL for portfolio. Is there a way to force change the URL from mydomain.com/portfolio to mydomain.com/mybooks?
Yeah. Change all instances of portfolio with mybooks in the PHP code in the functions file, template names and files as well as the CSS code and then resave your permalinks.
Brad and Sandee,
This can be done very easily.
Change the rewrite in the functions.php to this:
‘rewrite’ => array( ‘slug’ => ‘mybooks’ )
And now go to ‘Settings/Permalinks’ in wordpress and save the permalinks.
Done!
Thanks Woohoo.
Copy & rename portfolio custom post type in functions.php file
Your second step could use a little more detail. You say Copy and rename. Are you saying that the code should replace what is already in functions.php. Should it be added to what is already in functions.php? Thanks
Hi Kendall
You don’t replace the code for the existing portfolio otherwise it will not work.
You copy all the existing code and rename where needed so it creates a second portfolio page using unique i.d’s.
So its added to the existing code.
Hi Brad,
Is there a way of adding the portfolio to a section of a homepage and not just a page by itself?
Using the Minimum theme, I’m trying to add a portfolio section (3×7) underneath the 4 home-featured widgets and above the blog posts?
Not sure how easy this is though…
Brendan
You could easily add a gallery of images which look the same as a portfolio and link each image to any custom links.
Or you could add a new widget area in any hook position and use content columns for your portfolio images and titles.
Another option is a custom grid loop.
Some PHP coding knowledge will be needed in any case.