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.

38 thoughts on “Portfolio Post Type

  1. Jeroen Oosterveld wrote:

    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

    Reply
    • Devin wrote:

      Not sure. Try using the default theme (Twenty Eleven) and disabling all plugins except for the Portfolio Post Type. Does it work then?

      Reply
      • Jeroen Oosterveld wrote:

        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 wrote:

    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

    Reply
    • Devin wrote:

      It works. I just haven’t needed to update the plugin in a bit so it doesn’t have the latest in there. I’ll update it when I have a minute.

      Reply
      • Roberto wrote:

        Thanks for the info, I’ll give it a go.

        Cheers

        R.

  3. Ulf wrote:

    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.

    Reply
    • Devin wrote:

      You can tag or categorize the portfolio items. When you view the tag/category pages it will only show items in that section.

      Reply
      • Ulf wrote:

        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?

      • Ulf wrote:

        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 wrote:

    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?

    Reply
  5. Saranya wrote:

    hi thanks in advance can you plaease tell me how to add the portfolio to the page in my template display i dont have the portfolio template

    Reply
    • Devin wrote:

      That’ll need to be custom coded. You can look at how I did in it Portfolio Press though: https://github.com/devinsays/portfolio-press

      Reply
  6. Saranya wrote:

    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

    Reply
  7. Jeff wrote:

    What would be the best way to have these posts show up in a /work page vs a /portfolio page?

    Reply
    • Devin wrote:

      You can create a page “work” and select the portfolio page template. Otherwise, you’d need to edit the plugin and change the archive slug.

      Reply
      • emily wrote:

        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!!

  8. Ger wrote:

    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

    Reply
    • Devin wrote:

      There’s no option to do that. You would need to create a new page template that just displays the category you want.

      Reply
  9. Jeff wrote:

    Is there a way to order the portfolio items? Possibly manually setting the order?

    Reply
    • Jeff wrote:

      Hey mate, I ended up using this: www.nsp-code.com/wordpress-plugins/post-types-order/

      Reply
  10. Mathieu wrote:

    Hello !

    I have created a Portfolio page, put it in the menu, and set it to the full-width portfolio model.
    I have created 3 portfolio categories and put them in the menu, under the main Portfolio page.
    The problem is that those portfolio categories are displayed as simple portfolio model pages, and I would like to display them as full-width portfolio model pages, just like the main portfolio page.
    How can I do that ?

    I tried to create new pages but it doesn’t look to work well, or I am missing something.

    Thank you in advance for your answer, and congratulation for your theme, it’s great :)

    Mathieu.

    Reply
  11. Michelle S wrote:

    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

    Reply
    • Devin wrote:

      You mean you haven’t been visiting to the site every single day?! All good here in Austin. Hot.

      Reply
  12. Ana wrote:

    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!!!

    Reply
    • Devin wrote:

      If your code is set up correctly to output them there should be no issue. There’s restrictions on custom fields.

      Reply
  13. Christophe wrote:

    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!

    Reply
  14. Christophe wrote:

    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.

    Reply
    • Devin wrote:

      Yep, that’s the way to do with a custom taxonomy.

      Reply
  15. Gabriel Le Breton wrote:

    Typo on section What This Plugin Doesnโ€™t Do
    “font end display” instead of “front end display”

    Sorry to be an ass ;) Great plugin, thanks :)

    Reply
    • Devin wrote:

      Thanks. Proof-reading help always appreciated.

      Reply
  16. shabari shankar wrote:

    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

    Reply
    • Devin wrote:

      You can look what I did in Portfolio Press to show 9 items per page: https://github.com/devinsays/portfolio-press

      Reply
  17. Paul wrote:

    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?

    Reply
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.