• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WriteNowDesign - Wordpress and Ecommerce Website Design

WordPress, Joomla, Ecommerce Website Design

  • Home
  • Prices/Packages
  • WordPress
  • Services
  • Portfolio
  • Blog
  • About
    • Testimonials
    • Locations
    • Online Payment
  • Contact
  • Show Search
Hide Search

Call 303-907-6133 Email

How to Modify Genesis Search Results Page

How to Build a Portfolio for Genesis 2.0

August 7, 2013 by Pat Fortino

Create Portfolio Archive and Single Pages

  1. In your Genesis child theme folder, create a file called archive-portfolio.php
    This page creates the portfolio archive page and displays the title and featured image for each single portfolio page in a grid layout.
  2. Paste the following code in the archive-portfolio.php file and save it:
    <?php
    /**
     * The custom portfolio post type archive template originally by Brian Gardner at http://www.briangardner.com
    * Modified by yo for Genesis 2.0
     */
    /** Force full width content layout */
    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
    /** Remove the post info function */
    remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
    /** Remove the post content */
    remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    /** Remove the post image */
    remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
    /** Add the featured image after post title */
    add_action( 'genesis_entry_header', 'minimum_portfolio_grid' );
    function minimum_portfolio_grid() {
    	if ( has_post_thumbnail() ){
    		echo '<div class="portfolio-featured-image">';
    		echo '<a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">';
    		echo get_the_post_thumbnail($thumbnail->ID, 'portfolio' );
    		echo '</a>';
    		echo '</div>';
    	}
    }
    /** Remove the post meta function */
    remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    genesis();
  3. In your Genesis child theme folder, create a file called single-portfolio.php
    This page creates the individual, full-width portfolio pages.
  4. Paste the following code in the single-portfolio.php file and save it:
    <?php
    /**
     * The custom portfolio post type single post template 
     * originally by Brian Gardner at http://www.briangardner.com
     * Modified by me for Genesis 2.0
     */
     /** Force full width content layout */
    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
    /** Remove the post info function */
    remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
    //* Remove post comments in category ID #1
    /** Remove the author box on single posts */
    remove_action( 'genesis_after_entry', 'genesis_do_author_box_single' );
    /** Remove the post meta function */
    remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    /** Remove the comments template */
    remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
    genesis();

Add the portfolio code to your Genesis child theme functions.php

Open the Genesis child theme functions.php file and insert the following code. This code adds the custom portfolio post type to your theme:

Note: The code below includes taxonomy for tags. If you want categories, replace this ‘taxonomies’   => array( ‘post_tag’ ), with this ‘taxonomies’  => array( ‘category’, ‘post_tag’ ),

/* ----------------------- PORTFOLIO CODE --------------------------- */
/** Creates portfolio featured image for archive grid */
add_image_size( 'portfolio', 330, 230, TRUE );
/** Create portfolio custom post type */
add_action( 'init', 'portfolio_post_type' );
function portfolio_post_type() {
    register_post_type( 'portfolio',
        array(
            'labels' => array(
                'name' => __( 'Portfolio' ),
                'singular_name' => __( 'Portfolio' ),
            ),
            'exclude_from_search' => true,
            'has_archive' => true,
            'hierarchical' => true,
            'taxonomies'   => array( 'post_tag' ),
			'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
            'public' => true,
            'rewrite' => array( 'slug' => 'portfolio' ),
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
        )
    );
}
/** Change the number of portfolio items to be displayed (props Bill Erickson) */
add_action( 'pre_get_posts', 'minimum_portfolio_items' );
function minimum_portfolio_items( $query ) {
	if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
		$query->set( 'posts_per_page', '12' );
	}
}

Copy the Portfolio Menu Image

Right-click on the following portfolio image and save it to
/wp-content/themes/your_theme/images/icons portfolio

Add portfolio css rules to your theme’s styles.css

Add the following code to your child theme style.css file

/* portfolio
------------------------------------------------------------ */
.post-type-archive-portfolio .portfolio {
    float: left;
    margin: 0 15px 30px;
    width: 340px;
}
body.archive.post-type-archive-portfolio .entry:first-child {
padding-top: 30px;
padding-top: 3rem;
}
.portfolio-featured-image a img {
    -moz-transition: all 0.2s ease-in-out;
    -webkit-transition: all 0.2s ease-in-out;
    border: 10px solid #f5f5f5;
    transition: all 0.2s ease-in-out;
    max-width: 100%;
}
.portfolio-featured-image a img:hover{
    border: 10px solid #ddd;
}
.single-portfolio #content {
    text-align: center;
}
.single-portfolio article.portfolio img {
    border: 20px solid #f5f5f5;
}
article.portfolio .built-with img	{
	border: 2px solid #f5f5f5;
	padding: 4px;
	margin-right: 20px;
	display: block;
	float: left;
}
article.portfolio h2	{
	font-size: 18px;
}
article.portfolio .really_simple_share, article.portfolio .nr_related_placeholder	{
	display: none;
}
article.portfolio .entry-title	{
	width:50%;
	float:left;
}
article.portfolio .portnav	{
	width: 50%;
	float: right;
	text-align: right;
}
.entry-header.porthead {
padding: 40px 40px 24px;
padding: 4rem 4rem 2.4rem;
}
.attachment-portfolio.wp-post-image	{max-width: 85%;}
@media only screen and (max-width: 768px) {
	article.portfolio .entry-title	{
		 width:100%;
		float:left;
		font-size: 16px;
	}
	article.portfolio .portnav	{
		width: 100%;
		float: left;
		text-align: left;
		font-size: 14px;
	}
}
@media only screen and (max-width: 594px)	{
	.post-type-archive-portfolio .portfolio {
		float: left;
		margin: 0 15px 30px;
		max-width: 100%;
	}
	article.portfolio .entry-title	{
		 width:100%;
		float:left;
		font-size: 14px;
	}
	article.portfolio .portnav	{
		width: 100%;
		float: left;
		text-align: left;
		font-size: 14px;
	}
	article.portfolio .built-with img	{
		border: 2px solid #f5f5f5;
		padding: 4px;
		margin-right: 10px;
		display: block;
		float: left;
	}
	.custom-fields h3	{
		font-size: 14px;
	}
}

Optional – Add Custom Fields code to functions.php

The following code adds custom fields to your single portfolio pages. The reason I added these fields is because every time I created a portfolio entry, I had to insert a url and several thumnail images to indicate the CMS and template framework I used to build the site.

The following images show the custom portfolio fields in the Editor screen and on the single portfolio page.

Genesis 2.0 Portfolio Custom Fields
custom_fields_front
Pages: Page 1 Page 2 Page 3

Tagged With: genesis, WordPress, Comments are closed. If you have information to share, contact me here.

Previous Post: « Upgrading Mosets Tree from Joomla 1.5 to Joomla 2.5
Next Post: How to Customize Genesis Site Map Page »

Reader Interactions

Comments

  1. Renee says

    August 25, 2013 at 3:12 pm

    I very much appreciate you posting this code. I recently upgraded to WordPress 3.6 with Genesis 2.0.

  2. Nathan Schmidt says

    August 26, 2013 at 8:58 am

    Thank you for this tutorial. I had been trying to do this using a portfolio custom post type from another Studiopress theme I have and it wouldn’t work. Looks like some of the hooks have changed in the new Genesis 2.0 framework, which seemed to be the issue. My portfolio is working well, now.

    Would you have a recommendation on what to use to get the archive page to display the posts in a particular order based on the ‘order’ field in the custom post type? I originally used a custom field for ‘order’, but then I noticed that in WP, the ‘order’ field is already built in to the ‘attributes’ panel on the new post admin page. I used WP_query w/ an array in my archive-portfolio.php page to try to populate the posts by the ‘order’ I had designated, but I’m not having any luck.

    Any help would be appreciated… even a link to some documentation. I find a lot of posts on utilizing WP_Query, but nothing recent enough or along the lines of incorporating into a Genesis (2.0) theme.

    • Pat Fortino says

      August 27, 2013 at 8:02 am

      Not sure how to sort by order field. There are plenty of plugins that do that; seems like that would be easiest.

      • Nathan Schmidt says

        August 27, 2013 at 8:49 am

        I found a way to do it after breaking it a lot. I tried w/ WP_Query kind of unsuccessfully, but eventually, adding this in after the function that outputs the page header and before the function that plots out the posts got it to do what I wanted:


        query_posts( array( 'post_type'=>'product-categories' , 'orderby' => 'menu_order' , 'order' => 'ASC' ));

        Also, I saw on another post from Carrie Dils that activated the archive-page settings if you wish to add in content prior to the post output on the archive post page.

        I found this useful, as well. Basically, in the function registering the custom-post-type, you add in:

        ‘genesis-cpt-archives-settings’ into the register_post_type function’s array where ‘supports’ are listed.

        I found this to be a pretty cool baked in feature for Genesis 2.0

        • Pat Fortino says

          August 27, 2013 at 10:20 am

          Hi Nathan. Thanks for the update. I forgot about the genesis-cpt-archives-settings. I’m going to update my portfolio tutorial to include it since it makes adding a title or description to the ctp archive much easier.

          Regarding your comment:

          I noticed that in WP, the ‘order’ field is already built in to the ‘attributes’ panel on the new post admin page

          Not sure I understand what you mean. I don’t see any order field or option for it in the posts screen? Is this something you added using a plugin?

          • Nathan Schmidt says

            August 27, 2013 at 1:07 pm

            I have to correct that earlier statement. The page attributes panel is only located in the ‘page’ screen when making or editing a page, not post (located in panel to the right of the description field). I hadn’t realized that the tutorial made the custom post type more of a page layout rather than post, but it looks like by adding the ‘page_attributes’ in the ‘supports’ array in the registering function (in function.php), it adds this behavior.

            I suppose if you wanted to order posts in this manner, you could use a custom field and then integrate that into the query. This is likely why it wasn’t working before—I was trying to query posts rather than perhaps using something w/ page attributes. I hadn’t noticed this behavior until you brought this up. Now, I realize why it takes on the page attributes.

          • Pat Fortino says

            August 28, 2013 at 6:48 am

            Nathan. Thanks for that clarification.

  3. WriteNoWrong says

    September 11, 2013 at 1:23 pm

    Awesome tutorial! I know this wasn’t really covered, but how would you suggest going about adding custom taxonomies to said Custom Post Types and then presenting them?

    • Pat Fortino says

      September 11, 2013 at 1:33 pm

      The current code has taxonomies for tags. If you want categories, add category to taxonimies. See below.

      ‘taxonomies’ => array( ‘category’, ‘post_tag’ ),

      • WriteNoWrong says

        September 11, 2013 at 2:57 pm

        So say if I registered a custom taxonomy called “location.” I could theoretically just add that into the taxonomies line and it would present that data on the custom post type posting?

        ‘taxonomies’ => array( ‘location’, ‘category’, ‘post_tag’ ),

        • Pat Fortino says

          September 11, 2013 at 6:14 pm

          In order to create a custom taxonomy, you need to register it. See this url for explanation: http://codex.wordpress.org/Taxonomies

Related

Primary Sidebar

Blog Categories

Call Today

Get a Free Quote

303-907-6133

Subscribe to News

News about WordPress, WooCommerce, & Technology

What’s New

  • WPForms Not Sending Notifications
  • Add Terms and Conditions WooCommerce
  • Fix WordPress AMP Validation Errors
  • Use the Classic Editor with Gutenberg Block Editor
  • Add a Message at Top or Bottom of WooCommerce Checkout Page
  • How to Link to a PDF in WordPress

Find Us On…

  • Facebook
  • LinkedIn
  • RSS

Call 303-907-6133 Email

© 2004–2023 · WriteNowDesign · Sitemap · Log in · Return to Top

 

Loading Comments...