How To Add Portfolio Page To Eleven40 Theme

In this tutorial, i’ll provide all the working code i have tested locally which adds a portfolio page to the Eleven40 child theme by StudioPress.

You can use this code to create portfolio pages for all your category archives and display the featured image with or without post title and excerpt.

Here’s a screen shot taken from my local installation showing what it can look like.

eleven40 portfolio

The code creates a new widget where you simply drag in the Genesis featured posts widget and configure the settings to your liking.

There’s 2 simple steps involved:

  1. Create a new portfolio_archive.php template file
  2. Register a new widget in your child themes functions.php file
  3. Add some CSS code to your child themes style.css for the width and margins

Create Archive Template

Please copy and paste this code into a new file using a code editor and name it portfolio_archive.php

<?php
/*
Template Name: Portfolio
*/

/** Force the full width layout on the Portfolio page */
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

/** Remove the standard loop */
remove_action( 'genesis_loop', 'genesis_do_loop' );

/** Add the Portfolio widget area */
add_action( 'genesis_loop', 'wpsites_portfolio_widget' );
function wpsites_portfolio_widget() {
	dynamic_sidebar( 'portfolio' );
}

genesis();
[/code]

Note: You can change the name of this file and the code to something like category_archive.php and use it to create multiple portfolio style archive pages.

<h3>Add New Widget & Image Size</h3>

[code]
add_image_size( 'portfolio', 360, 230, TRUE );

// Register widget areas
genesis_register_sidebar( array(
	'id'				=> 'portfolio',
	'name'			=> __( 'Portfolio', 'eleven40' ),
	'description'	=> __( 'This is the portfolio page.', 'eleven40' ),
) );

This code registers a new widget which you can also modify for each category. It also creates a new image size for the portfolio featured image. This size can also be changed however it does fit perfectly 3 across on the archive page.

Style Portfolio Archive Pages

Please paste this code at the end of your child themes style.css file.

.page-template-page_portfolio-php h4 {
	font-family: 'Lora', Georgia, "Times New Roman", Times;
	font-size: 42px;
	line-height: 1.25;
	margin: 10px 0 25px;
}

.page-template-page_portfolio-php h2,
.page-template-page_portfolio-php h2 a,
.page-template-page_portfolio-php h2 a:visited {
	font-size:clamp(14px, 0.875rem + ((1vw - 3.2px) * 0.625), 20px);
	margin: 10px 0;
	text-align: center;
}

.page-template-page_portfolio-php .featuredpage img,
.page-template-page_portfolio-php .featuredpost img {
	margin: 0 0 10px;
}

.page-template-page_portfolio-php .featuredpage .page,
.page-template-page_portfolio-php .featuredpost .post {
	float: left;
	margin: 0 10px 30px;
	padding: 0 0 20px;
	overflow: hidden;
	width: 360px;
}

Again, the name of the portfolio page template class can be changed to something like .page-template-page_category-php if you want to use the portfolio for different category archives and style them differently.

Important Tips

  • Resave your permalinks after adding the PHP to your functions file
  • Crop/Resize your images to the exact same as your settings (360 x 230) before adding them as featured images for each single custom post

Genesis Featured Post Widget Settings

Time to hit your widgets page and drag in the Genesis Featured Post widget into your new Portfolio widget area. Here’s the settings i used.

genesis featured post widget

Displaying featured images for posts in a portfolio style category archive may help attract more traffic to these archives as its a more visually attractive way to search for posts in an archive.

You’ll also find more posts on this site with code that does exactly the same thing for use on other themes.

Video Result (With Relaxing Music)

Here’s the video showing you the result of adding the code above and how it works.

What do you think? Like it or not?


Comments

23 responses to “How To Add Portfolio Page To Eleven40 Theme”

  1. Does this work with Eleven40 Pro as well? Just wanted to check before I start messing around with things.

    1. Brad Dalton Avatar
      Brad Dalton

      Yes but better to use this tutorial http://wpsites.net/web-design/add-responsive-portfolio-page-to-lifestyle-pro/

      You may need to tweak the CSS a little as all themes are slightly different.

  2. Brad,
    I’ve got things working satisfactorily except for the responsive aspect. (billyhassell.com/work/lithographs)
    (Note: I am just creating multiple archive templates since I can’t figure out how to work a true template that employs the portfolio widget.)

    I’ve tried the following code to make the featured post widget responsive (starting with max-width:800px):

    .widget featured-content featuredpost {
    margin: 0 auto;
    width: auto;
    float: none;
    text-align: center;
    }

    Ideas?

    Thanks.

    1. Brad Dalton Avatar
      Brad Dalton

      Hi David

      It looks good to me when i re-size your portfolio pages.

      You can use this code as a guide or the code from my recent post about how to add a responsive portfolio page to the new Lifestyle theme:
      [code]
      @media only screen and (max-width: 767px) {

      .site-container {
      max-width: 600px;
      }

      .eleven40-portfolio .portfolio{
      margin: 0;
      width: 100%;
      }

      .eleven40-portfolio .portfolio {
      text-align: center;
      }

      .eleven40-portfolio .portfolio {
      padding: 0 0 30px;
      padding: 0 0 3rem;
      }
      [/code]

  3. In switching from the smaller size (250 width) to 360, I replaced all the images with the new size.

    I deleted the old ones from the media library, removed and replaced the old featured images with the new ones,

    But, you guessed it, the old one keep coming back.

    Only the new poat (for which I had not posted a featured image in the smaller size) is it displaying correctly.

    Any idea how to purge the old images?

    SECOND QUESTION

    How do you create additional portfolio pages?

    1. Brad Dalton Avatar
      Brad Dalton

      Looks like you got it working David, Good stuff!

      Maybe the caching is showing the old images.

      I would make sure you crop your images to exactly the same size as the settings before adding them as featured images on all single CPT edits screens.

      The portfolio will paginate according to the settings in the code. If you adding 24 posts to your portfolio and the setting display 12 per page, you will have 2 pages of the portfolio archive.

      Or you can duplicate the code and use another name for your portfolio if you want a 2nd portfolio.

  4. Resized all the images and changed the template, functions.php, and css to reflect size of 250 x 159.. Still lining up in a single column.

    1. Brad Dalton Avatar
      Brad Dalton

      I would stick to the size in the code because that works.

      The code has been written to display a 3 column portfolio, not 4.

  5. I figured incorrectly on the width to fit four columns (no room for margins). Will attempt later with 250 width.

    1. Brad Dalton Avatar
      Brad Dalton

      I didn’t test the code for 4 across so not sure its possible however it works with the code i tested.

      May work if you reduce it to around 250px.

  6. Changed sizes to 270 x 172 to fit four across in eleven40.

    All thumbnails are coming out vertically rather than in rows of four columns.

    http://billyhassell.com/oil-on-canvas/

    Ideas?

    Thanks.

    1. Brad Dalton Avatar
      Brad Dalton

      Hi David

      Go to Settings > Appearance and re-save your Permalinks.

      If that doesn’t work, you must have a problem with the CSS code.

      What width did you use?

  7. richard Avatar

    Hi Brad,

    Under “Add New Widget & Image Size”, where in the function.php of the child theme should I placed the code?

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Richard

      You can paste that code at the end of your child themes functions.php file or near the start of the file if you like.

  8. Works perfect. Thank you 🙂

    1. Brad Dalton Avatar
      Brad Dalton

      No worries Paul.

  9. Brian Dusablon Avatar
    Brian Dusablon

    Interesting. I’ve followed the tutorial exactly. Even tried it with a brand new download of Eleven40. I’ll try it locally and see if it works.

    1. Brad Dalton Avatar
      Brad Dalton

      I’ll send you a copy of my local files if you like so you can see that it works perfectly.

  10. Brad Dalton Avatar
    Brad Dalton

    Must have missed something Brian because all the code i provided works. That’s how i took the screenshot.

    Try saving your permalinks.

    1. Works for me too in localhost.

  11. Great how to!! Is it necessary to crop/resize all images or can I use the
    Regenerate thumbnails
    Plugin?

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Joan

      I think its best to crop all images because then you can check the quality before uploading them rather than relying on the code to resize them.

      If the aspect ratio resizes perfectly according to your image settings, then that’s ok as well but if it doesn’t, your images won’t look the best.

      Example:

      600 x 300 resizes perfectly for a 300 x 150 featured image

      700 x 300 doesn’t

      Personally, i add featured images which are 600 x 300 because then i can use them in a slider or content area and know they resize perfectly for a featured image displayed in an archive.

      1. Great point. Manual is always better! Also takes more much time but it’s worth it! Thanks again!

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.