Portfolio Post Type

I’ve used custom post types to display portfolio items since WordPress 3.0 when they were first introduced.

Portfolios work well as a custom post types because they generally aren’t displayed in the regular feed (like posts), they usually need a taxonomy (which isn’t done in pages by default), and as a custom post type its easier to give them their own metaboxes (like a project link, or image).

However, if you register a “portfolio” post type directly with the theme- whenever you change themes you’ll need to copy over the code code. And since I just recently did this, I thought I might as well release my code as a plugin and let other folks do it as well.

What This Plugin Does

The Portfolio Post Type Plugin will:

  • Registers a new portfolio post type
  • Registers separate portfolio taxonomies for tags and categories
  • Displays the portfolio image in the dashboard column view

What This Plugin Doesn’t Do

This plugin won’t handle any of the front end display of your post type. If you want to style those or change the layout, you’ll probably want to add archive-portfolio.php and single-portfolio.php to your theme.

When You Shouldn’t Use This Plugin

If you want your portfolio items to go out in the regular feed, or be displayed alongside posts- you’ll likely want to use post formats instead. With a post format you can set your post as an “image” or a “gallery”, and even display it differently on the front end using custom templates. Here’s a link to the codex about post formats.

How Does the Code Work?

I wrote a full explanation of the plugin code over here.

144 Responses

  1. Hi Devin,

    I’d like to use your Portfolio Post Type plugin. So I followed you instruction-video.
    After installing and activating the Plugin, option “Portfolio” is not shown in the left bar of the Dashboard.

    Can you please tell me why?

    Many thanks in advance.

    Gr. Jeroen

      1. Hi Devin,

        Thanks for your fast reply.

        I already got the idea last night, and it works!
        I swithced to the default theme and removed all plugins.
        Then I installed your Theme again and your Portfolio Post Type plugin and now, the option “Portfolio” appereas in the left column of the dashboard.

        Thanks!

        Regards,
        Jeroen

  2. Roberto

    Hi Devin,

    Question about version compatibility: I recently installed WordPress 3.3.1 and Portfolio-Press 1.0. Right away I got a message to update the Portfolio Post Type Plugin. Yet when I click “install now” I get a warning that says “plugin has not been tested with your current version of WordPress” and a notice indicates that the plugin is compatible up to WordPress 3.2.1.

    Does this mean I should not use the portfolio post type with WordPress 3.3.1 or is there a way to work around this dilemma?

    Thanks in advance for any assistance.

    Roberto

  3. Ulf

    Hi Devin, is there any way to use multiple portfolios on a website? We’re trying to use two different Portfolio galeries on our website, but after integrating a second page with the type of Portfolio all the “old” Portfolio items were displayed. Thanks for your help.

      1. Ulf

        OK, did that. Now I tried to add the link to the newly created category to my menu. But the menu section is greyed out, I can’t create any custom elements. My fault or doesn’t the theme have this capability?

      2. Ulf

        Ah, forget it, stupid me. Didn’t get the concept of the menus at first. Not it works after adding a custom menu. Thanks anyway :).

  4. Ulf

    Well … me again. I discovered another problem with this workflow. I’m using the Portfolio in a static page as a startpage for my website. Thus, the frontpage displays every Portfolio item available. Is there any way to filter this without using the direct link to the category?

  5. how to display only certain categories in a page for example if i have 4 categories i want two categories in a page and other two in another page….
    Thanks in advance

      1. emily

        Hi there, can you clarify what you mean by ‘edit the plugin and change the archive slug’? i need to display certain categories on certain pages. please help, and thank you!!

  6. Ger

    HI, I’m trying to set up 2 portfolio pages using your plugin. I have created two portfolio categories and assigned images to the various categories. When I add a new page and choose the portfolio template how do i choose the category to be shown, cant see an option to do this. Thanks in advance.

    ger

  7. Hi Devin,

    Just took a look at your updated WP Theming site. Looks like there is a plethera of information there!

    Looking forward to getting a bit of tie to dive in.

    How’s Austin treating you?

    Michelle Samuel

  8. Ana

    Hi!! I’m trying to add custom fields in the Portolio’s post and it doesn’t show in the public site. I add for example after .
    Is there some restriction about that?
    Thanks in advanced!!!

  9. Christophe

    Hey,

    I’m looping through all the posts in my portfolio and I’m trying to add a class for each post. This class should be the post’s category, but I can’t seem to print out the post category.

    Any ideas?

    Thanks already :) Keep up the good work!

  10. Christophe

    Hey,

    After quite the while of experimenting I ended up using the following bit of code to print the post category in plain text.

    echo strip_tags(get_the_term_list( $post->ID, 'portfolio_category'));

    Quite simple when you look at it. Is there a better way?

    Thanks again.

  11. shabari shankar

    Hi Devin,

    there are a total of 7 portfolios in my design, i want to display only 2 selective portfolios for a particular page and the remaining 5 should not be visible. is there a way to do it

    Cheers,
    Shabari

      1. andy

        Could you tell me what you did to get 9 per page. As standard portfolio post types show 7 per page which is annoying as I have 8 portfolio items. 9 would be handy as I could always add another one in the future. This plug in is lacking a “settings” option to increase how many posts per page

  12. Paul

    In creating archive-portfolio.php and single-portfolio.php in the theme folder, is there more involved in getting them to work? Do I need to register these somewhere so WP knows to use them?

    single-portfolio.php seems to work, but WP keeps using archive.php
    Any tips?

  13. Rebecca

    Hi Devin,

    Could you please elaborate on creating several separate portfolio sections? Ideally I would like several pages with separate portfolio galleries on each page. Ie. “Portfolio”, “current work”, “commissions”.

    You also mentioned using a drop down menu to select pages. Is this something I would have to code into the theme? Or is the functionality already there?

    Thanks,
    Rebecca

  14. Jing Xu

    Great theme. Everything works fine so far. But I want to used blog editors such as “Scribefire” or “Windows Liver Writer”. Is there a way to get them showing the portfolio post type?

  15. How use Plugin Portfolio Post Type to add more than one image?
    Must of projects hav emore then one unique picture.
    How do this? don’t add images via normal post, its appear different size and border, like more to do that directly when add image when i make “add new portfolio”

  16. Tandarts

    Hello.

    Thank you for the great plugin. This plugin is just what I was looking for.
    I have only one question. I want to rename the portfolio to images or something else.. How can I do this and is it easy to do?

    I’m not very good at php or things like that ( true blond LOL) but I was hoping you could help me

    Thank in return !!

      1. Tandarts

        Thank you so much !! I was almost pulling my hair out for not finding the solution. I’m a reall php noob and never guessed it was so simple.

        doing happy dance now :)

  17. Hi Devin,

    I may a well tell you this is my first time using word press and your responsive temple is exactly what I was looking for but Im having trouble I followed your vid but I wasn’t getting the tab image first and couldn’t find a way back to the image or put them together into a portfolio page.

    I was wondering was there an issue with the plug in because the portfolio icon is gone (all blurred ) and the one time I got the tabs up the black colour that comes over the tab image was blinking like rave lights.

    Thanks,
    Lorcan

  18. vianney

    Hi Devin,

    I’d like to use your extension, but I don’t know how to display the portfolio in my website, in the twenty twelve theme; what do I have to write ? I also don’t know how to add a Thumbnail.
    Thanks,

    Vianney

  19. Hi Devin, I would like to ask you. Is it possible to remove or hide the “Posted on” by ? I tried to look for it and google it without any luck. I also using your Portfolio Press theme. Is it somewhere at the loop.php or CSS style ?

  20. Hey, Devin. Found your blog a few years ago and come back now and again, using it as a reference for WP coding related subjects. Thanks for all the knowledge.
    A theme I am developing has an integrated custom post type called albums which utilizes a few custom templates (archive-albums.php, content-albums.php, etc.). What I want to do is transfer this functionality, along with the template files, into a plugin for the sake of portability. I easily transferred the CPT code but when I try to pull the template files over, things fall apart. Did a search and read a few (otherwise) informative blogs, then I thought of your portfolio post type plugin and thought I could figure it out by picking it apart. I see you instruct people to create custom templates and put them in the theme directory.
    Here’s the question: Can custom template files be stored within the plugin folder or must they be in the theme folder? I feel like it should be simple to somehow register the templates so WordPress knows to load them. Thanks in advance!

  21. Ramune

    I am one of what looks like a number of people who want to use archive-portfolio.php and single-portfolio.php in the template I am already using, but am having trouble figuring out exactly what code I need in the function.php to make the two work. I am a beginner with php, but am not afraid to get into the code if I can get some instructions. I copied lines 222-245 of your code in the function.php on portfolio-press, but my pages are now just blank. I am sure I am missing a lot.

    Thank you for your help!

      1. Kamilla

        Probably because I’m not all that experienced in programming, and I don’t know how. I’m guessing I’ll have to learn it now :)

  22. Winy Schalke

    Could you add a body class to custom post types with the category(s) and/or the tag(s)? And/or the parent or ancestor categories? I need this to style the parent menu links in the menu.
    My menu is like this: Portfolio > Paintings > Boats > Boat 1.
    Or can the parent and ancestor categories in the menu get the class “current-page-parent” or “current-page-ancestor”?
    I hope you can help me.

  23. Kim marketing

    Dear Devin!
    I want to create a page with my porfolio & They will paging in this page. This plugin can help me do this ? How must I do?
    Thank you!

  24. Jonathan

    Hi Devin

    I hope you can help me, I need to have a portfolio for my site but I need separate information on it for “designer” and “model”, an example “models” need to add body dimension’s but I don’t need that information displayed for “designer”. My thinking is styling the categories accordingly so the “models” display off one template and the designers display off another. I have attempted to change this via the single.php file so that it looks at category(‘1’) but nothing displays. The current code inside my single.php is

    I have downloaded your plugin but will have to strip the current built in taxonomy for portfolio out, I don’t mind doing that but I for see a similar problem using your plugin. Please any help would be appreciated, as I have been turned away by wordpress.org and otw for assistance so far.
    Thanks

  25. Rajeshkannan MJ

    Dear Devin,

    I need your HELP please. sorry for the caps. But I am in real need of your help.

    I have been working with custom post types for lots of days. Recently I saw your plugin and a free theme. It is a wonderful job and contribution to the WP community.

    ok, here is my question. I see that your theme uses archive-portfolio.php .

    The great thing in it is, this file is used for both taxonomy and custom post type archive.

    But when i create my own custom post type and taxonomy the archive-{custom post type}.php does not work at all.

    Yes, I resave permalinks, also set “has_archive” , but yet archive-custom.php not at all working. I mean when i go to custom taxonomy page, it loads index.php file only.

    Kindly reply what i am missing. I am working on it for more than a day to fix it. Though I am not a programmer, I want to achieve it.

    Thanks for your help Devin,

  26. hhins

    Hey Devin, I love your work.

    I’m struggling with the thought process on displaying custom post types in a portfolio plugin shortcode while maintaining pagination, single post type pages and such without resorting to a custom page template, any tutorials/plugin examples you approve of? ( Otherwise, I’d need to bundle page templates with my plugin which isn’t ideal )

  27. Just got the widget area to work by referencing is_tax(‘portfolio_category’) instead of is_tax(‘portfolio-category’) whoops! Still having trouble with calling the active page portfolio category name… I’m using this:

    But it’s not working… any suggestions?

  28. philip ebels

    Hi,

    Thank you for a useful plugin.

    One problem, however, is that the filter and search functions in the admin area don’t seem to work. They both always return “No portfolio items found” even though they clearly should find some.

    Any thoughts?

      1. I found the solution.

        In the plugin code, in the add_taxonomy_filters() function, replace:

        echo ” . esc_html( $tax_name ) .”;

        with

        echo ” . esc_html( $tax_name ) .”;

        That’s it!

  29. Chris Holt

    Hi Devin,

    I want to include embedded Google map APIs as portfolio items. Have you ever had that request before?

    Is there a way to set that as a post type? Sorry I can’t be more specific. There seem to be a lot of variables to factor in.

  30. Just wanted to add a little note. I was trying to get archive_portfolio.php to work for my portfolio archive, but it just kept using archive.php. I found out that I had to use taxonomy-portfolio_category.php for it to work, but that was never mentioned in your plugin description so it took me some time to figure that out even though it’s a great plugin.

  31. To: Devin

    I use your Portfolio Post Type plugin and I appreciate of it coz it really helps me.
    But I got a problem of how could I get all the list of my category (say its 10 categories). I use WordPress Foundation V2.0 as my theme in wordpress. I tried what is been suggest from this SITE but doesnt work well for me. Hope you could help me.

  32. Roddy

    Hey Devin,

    Your plugin is pretty sweet! However, is there anyway to make the portfolio detail page full width? I want to drop the right hand column completely.

    Thanks,
    Roddy

  33. Hi, After updating WordPress to 3.8 I got a blank screen instead of my site.
    In the code I see the that the body tag with its background image (through css) is loaded but this body is empty. After some testing I concluded that the error was within your plugin, which I updated to te latest version (0.7.0). After re-installing the previous version (0.6.1) the site and portfolio worked as expected.

  34. Hi Devin,

    Thanks for the awesome plugin, I came pretty close to what I want to achieve. But I cant figure out one thing:

    Is it possible to display portfolio items from a specific category, on a static page? Could you point me in the right direction please?

    Thanks

  35. thanks a lot for your quick response Devin! I came across the article you mentioned, however, when I try to exclude categories from the portfolio template it doesnt work.. (e.g. cat=-31)

    You can check out the code that i’m working with her:
    https://wordpress.org/support/topic/portfolio-template-get-category

    I know it has to do something with the “have_posts() ) : $wpex_port_query->the_post(); ?>” line, but I dont know how to do it. So frustrating. Can you please help me with this Devin?

    Kind regards,

    Rick

  36. Hi!

    I love your plugin, it’s so simple that it’s beautiful.

    I’d like to suggest you if you can add:

    'with_front' => false,

    In the slug rewrte. This way, when we have a permalink structure for posts, it won’t affect the portfolio pages -which we use to want-.

    Thanks!

  37. I have read the above comments but am still confused about how to separate portfolio items into different portfolios, “Artists” and “Sponsors,” for example. Is it just a matter of adding tags and categories into each portfolio item and they will filter themselves into the appropriate portfolio collection or is there a step I am missing?

  38. Hey guys,

    I bought a theme about 2 years called “Stoodio” that had this plugin built in. The theme was taken off of theme forest and now I’m having some issues. The problem that I’m currently having is that I’m using portfolio to display a bunch of thumbnails and each one redirects you to a page with a video. I have 4 videos in each row and only 3 rows are viewable unless you click an arrow that SHOULD scroll over to the next set of images, but it doesn’t. The link changes and says that its showing page 2 but the thumbnails don’t change. Any ideas?

Leave a Reply