If you have many design projects, it is good to let your clients sort them by some criteria like type, industry etc.
This tutorial tells you how to build sortable portfolio like PROWEBDESIGN’s. We will also cover how to optionally add jQuery animation effects to the sorting script.
PROWEBDESIGN portfolio is made with WordPress 3.0.3 and is built upon Twenty Ten theme, so this is what we will refer to in this tutorial.
This tutorial assumes that you are fairly familiar with WordPress, FTP clients and web design.
Step 1: Install latest version of WordPress which includes Twenty Ten default theme on your server.
Step 2: After everything is in place and working, go to the wp-content -> themes folder, make a copy of Twenty Ten theme and rename it e.g. “myTheme”
Step 3: Activate myTheme (in your blog’s admin -> appearance -> themes section). Now any changes you make to myTheme files will show up in your browser.
Step 4:
First we will make sure that our portfolio gets sorted, and style it afterwards. So, let’s begin with creating a link to jQuery. The correct way to add jQuery to WordPress is called enqueue-ing. You can enqueue jQuery either from default location (it is already distributed with WordPress) or grab it from Google CDN. In this tutorial we will enqueue it from default location.
Open header.php file (remember that we are working on myTheme!).
Paste this code somewhere between <head> and </head>, but take care to past it BEFORE wp_head(); hook:
<?php if (!is_admin()) { wp_enqueue_script("jquery"); }?>
This bit of code enqueues jQuery outside of admin area. Upload header.php to the server (if you were editing it locally).
Reload your theme in the browser, and view source to make sure that a link to jQuery did appear in the head section.
Step 5:
Open footer.php file and paste this code somewhere after </footer> tag, but before wp_footer(); hook.
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#filters a').click(function(e){
e.preventDefault();
var filter = $(this).attr('id');
$('#sortable-portfolio div').show();
$('#sortable-portfolio div:not(.' + filter + ')').hide();
});
});
</script>
Upload footer.php to the server.
Step 6:
In admin panel of your blog create a Portfolio category. Then create several posts in this new category. To style posts nicely (later on) we will be using custom excerpts. So, for now just type a paragraph of “Lorem ipsum” in excerpt field of each post of Portfolio category.
Step 7:
Assign tags to each post in Portfolio category. Tags should reflect your sorting criteria. In this tutorial we will sort web design projects from logo design projects. So, add tags ” web design” to some posts and “logo design” to other posts. Now, if you look at the source code of Portfolio category, you’ll see that every post has tag-web-design or tag-logo-design in its class attribute
Step 8:
Now we will insert the actual sorting links into category page. Open category.php and insert this code under the page title:
<?php if(is_category(1)){?>
<div id="filters">
<a href="#">all projects</a> | <a href="#" id="tag-web-design">web design</a> | <a href="#" id="tag-logo-design">logo design</a>
</div>
<?php } ?>
Take care to change category ID in if(is_category(1)) to the actual ID you have on your category!!
Then, also in category.php change exactly this line of code
get_template_part( 'loop', 'category' );
?>
into this:
?>
<div id="sortable-portfolio">
<?php
get_template_part( 'loop', 'category' );
?></div>
Upload category.php to your server.
Step 9:
Now we will rearrange the way excerpts are shown in Portfolio category. Open loop.php
Right under the loop
<?php while ( have_posts() ) : the_post(); ?>
insert this code:
<?php if (is_category(1)) : // How to display posts in Portfolio CATEG ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
</div><!-- #post-## -->
Right below inserted code you should have the following statement that shows posts in Gallery category:
<?php /* How to display posts in the Gallery category. */ ?>
<?php if ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
You should change it into this, otherwise you will get an unexpected T_ENDWHILE error:
<?php /* How to display posts in the Gallery category. */ ?>
<?php elseif ( in_category( _x('gallery', 'gallery category slug', 'twentyten') ) ) : ?>
*Note elseif instead of if.
Upload loop.php to the server.
At this point you should be able to do the sorting!
Step 10:
Next step is to add some CSS styling to the excerpts and sorting links.
You can style excerpts using values of body class attribute. Your category page will have category-portfolio value in its body class. So, you can write a style for your excerpts like this:
.category-web-design .post {
background:#F2EFEC;
border:1px solid #CFCBB1;
float:left;
margin-right:20px;
padding:10px;
width:320px;
}
This style will give you 2 columns of project excerpts. If you want to show them one per row, or 3 per row – just change the width.
You can also easily insert pictures in the excerpts from any location on the web, or from your wp-uploads.
You can also display your sorting links in an unordered list, instead of inline.
Step 10 (optional):
You can also add jQuery animation to the sorting script.
Click here to open jQuery documentation. There you have a list of possible animation effects. Applying them is very easy. In footer.php, where we have pasted the sorting script, just substitute for starters
$('#sortable-portfolio div').show();
with
$('#sortable-portfolio div').fadeIn();
and
$('#sortable-portfolio div:not(.' + filter + ')').hide();
with
$('#sortable-portfolio div:not(.' + filter + ')').fadeOut();
Go to your browser and play with it. You can use other animation effects, set duration, easing, etc.
Have fun.

[...] the rest here: Sortable design portfolio with WordPress 3.0, tags and jQuery … This entry was posted in Web Design, WordPress and tagged logo-design, portfolio, posts, [...]
thanks for article it’s really great
Hi, do you have a demo or example link of above tutorial?
Thak you!
Hi. Yes, portfolio section of this site is made as described in the tutorial. Here it is: http://www.prowebdesign.ro/category/portfolio/web-design/
Hello! I tryed to install it in a custom post archive page.. do you know if this code works only in a category page?
Hi. It can basically work anywhere with some little effort;). I don’t know how you created your custom archive page exactly, but in order to change what is sorted in a way described in this tutorial, you should customize the code from step 8. Meaning, changing code, which refers to category to some other code, referring to < ?php wp_get_archives( $args ); ?> or whatvere it is you are using.
Hi, thanks for the post. I’m having one problem.
I have two portfolio items with a portfolio tag of “home featured” that I’m displaying on my home page only.
Unfortunately they are also showing up on my portfolio page under the category “all” how would I go about excluding these two portfolio items from the “all” filter?
Hi Steve.
what if you simply don’t include those posts in Portfolio category? Or this is not an option?
Is there a way we can do the above, but using a twentyEleven child theme?
Thank you.
Hi Deyson. There ARE some differences between loop code in twenty ten and twenty eleven. But I don’t see why the solution wouldn’t work with twenty eleven or it’s child theme. The difference will appear in step 8.
Hello Irina. I noticed that in twenty eleven there is no loop in the them. So should I drag the loop.php from the twenty ten them into my child theme?
Thank you
I have created everything just as said but the link that should bring up all the tags just shows up blank when I click it. It doesn’t take me to a new page or reload this one it just doesn’t bring any of my portfolio items up. Any ideas? I am using the twenty ten theme and I have added a few other plugins as this is my testing theme for things like this. also, I’m using version 3.3.1
Great tutorial! After following your directions, my sorting is worked great, but the ‘all projects’ link wasn’t working. I added a second function if the Footer’s javascript specifically targetting the ‘all projects’ link so when it’s clicked: $(‘#sortable-portfolio div’).fadeIn(); This solution might not be the most DRY but it solved the issue for me.