Create a Quicksand Portfolio With WordPress

Create a Quicksand Portfolio With WordPress

Tutorial Details
  • Program: WordPress
  • Version: 3.0+
  • Difficulty: Intermediate
  • Estimated Completion Time: 60 Minutes

Today, you will change your simple portfolio into something amazing with the magic of Quicksand by Razorjack.


Introduction

Ever wanted to use the jQuery plugin Quicksand? Ever tried to implement it with WordPress? But, found it a nightmare to do both? Well, I will be going through a simple step-by-step guide to get you from a blank WordPress theme to a beautiful custom portfolio with the use of Quicksand. I’ll be using a custom theme which has been stripped down for the purpose of this tutorial along with WordPress 3.0+.

So open up your favourite text editor and let’s begin!


Step 1 Create a Post Type

With WordPress, we are capable of creating custom post types where we can manage all of our content. We will create a custom post type to store all of our portfolio items in a dedicated admin section.

For easy code management, let’s begin by creating a folder called portfolio and a PHP file called portfolio-post-types.php (or anything you find suitable).

Once you have created a file, let’s add some code…

Let’s start by creating a function:

<?php

	// function: post_type BEGIN
	function post_type()
	{
		// We will fill this function in the next step
	} // function: post_type END

Now that we have created our blank function, let’s add some code to make this function do something special. First, create the labels for our custom post type. Insert the following piece of code in our post_type function:

$labels = array(
	'name' => __( 'Portfolio'), 
	'singular_name' => __('Portfolio'),
	'rewrite' => array(
		'slug' => __( 'portfolio' ) 
	),
	'add_new' => _x('Add Item', 'portfolio'), 
	'edit_item' => __('Edit Portfolio Item'),
	'new_item' => __('New Portfolio Item'), 
	'view_item' => __('View Portfolio'),
	'search_items' => __('Search Portfolio'), 
	'not_found' =>  __('No Portfolio Items Found'),
	'not_found_in_trash' => __('No Portfolio Items Found In Trash'),
	'parent_item_colon' => ''
);

A breakdown of the code we have just written:

The ‘labels’ variable is an array of strings that represent your post type, each of the strings are text which is output for the particular function.

  • name – The plural form of the name of your post type.
  • singular_name – The singular form of the name of your post type.
  • rewrite – Rewrite permalinks with this format.
  • add_new – The menu item for adding a new post.
  • edit_item – The header shown when editing a post.
  • new_item – Shown in the favourites menu in the admin header.
  • view_item – Shown alongside the permalink on the edit post screen.
  • search_items – Button text for the search box on the edit posts screen.
  • not_found – Text to display when no posts are found through search in the admin.
  • not_found_in_trash – Text to display when no posts are in the trash.
  • parent_item_colon – Used as a label for a parent post on the edit posts screen. Only useful for hierarchical post types.

Next, create the arguments for our custom post type. Insert the following piece of code into our post_type function:

$args = array(
	'labels' => $labels,
	'public' => true,
	'publicly_queryable' => true,
	'show_ui' => true,
	'query_var' => true,
	'rewrite' => true,
	'capability_type' => 'post',
	'hierarchical' => false,
	'menu_position' => null,
	'supports' => array(
		'title',
		'editor',
		'thumbnail'
	)
);
  • labels – An array of labels for this post type.
  • public – Meta argument used to define default values for publicly_queriable, show_ui, show_in_nav_menus and exclude_from_search.
  • publicly_queryable – Whether post type queries can be performed from the front end.
  • show_ui – Whether to generate a default user interface for managing this post type.
  • query_var – False to prevent queries, or string value of the query var to use for this post type.
  • rewrite – Rewrite permalinks with this format.
  • capability_type – The string to use to build the read, edit, and delete capabilities.
  • hierarchical – Whether the post type is hierarchical. Allows parent to be specified.
  • menu_position – The position in the menu order the post type should appear in the admin.
  • supports – An alias for calling add_post_type_support() directly.

Read more about add_post_type_support in the WordPress Codex

Now our post type is setup with the settings, we need to register the post type. We register our post type by inserting the following code into our post_type function:

register_post_type(__( 'portfolio' ), $args);

Format Custom Post Type Output

We now have our custom post type created. Let’s format the output, so we can get user-friendly messages. Begin by creating another function within our portfolio-post-type.php file.

// function: portfolio_messages BEGIN
function portfolio_messages($messages)
{
	$messages[__( 'portfolio' )] = 
		array(
			0 => '', 
			1 => sprintf(('Portfolio Updated. <a href="%s">View portfolio</a>'), esc_url(get_permalink($post_ID))),
			2 => __('Custom Field Updated.'),
			3 => __('Custom Field Deleted.'),
			4 => __('Portfolio Updated.'),
			5 => isset($_GET['revision']) ? sprintf( __('Portfolio Restored To Revision From %s'), wp_post_revision_title((int)$_GET['revision'], false)) : false,
			6 => sprintf(__('Portfolio Published. <a href="%s">View Portfolio</a>'), esc_url(get_permalink($post_ID))),
			7 => __('Portfolio Saved.'),
			8 => sprintf(__('Portfolio Submitted. <a target="_blank" href="%s">Preview Portfolio</a>'), esc_url( add_query_arg('preview', 'true', get_permalink($post_ID)))),
			9 => sprintf(__('Portfolio Scheduled For: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Portfolio</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime($post->post_date)), esc_url(get_permalink($post_ID))),
			10 => sprintf(__('Portfolio Draft Updated. <a target="_blank" href="%s">Preview Portfolio</a>'), esc_url( add_query_arg('preview', 'true', get_permalink($post_ID)))),
		);
	return $messages;

} // function: portfolio_messages END

What we have just done is create a function called portfolio_messages that takes an argument called $messages. Following this, we are creating a variable which stores an array for all of our messages. We leave “0″ blank within our array because we begin our indexing at 1 with our messages. Then finally return our array to our function.

Create Taxonomy

Finally, we need to create our taxonomy. Begin by creating another function called portfolio_filter and input the following code:

// function: portfolio_filter BEGIN
function portfolio_filter()
{
	register_taxonomy(
		__( "filter" ),
		array(__( "portfolio" )),
		array(
			"hierarchical" => true,
			"label" => __( "Filter" ),
			"singular_label" => __( "Filter" ),
			"rewrite" => array(
				'slug' => 'filter',
				'hierarchical' => true
			)
		)
	);
} // function: portfolio_filter END

We begin by registering our taxonomy and then applying the taxonomy to our custom post type portfolio. Following this, we apply the final settings of the taxonomy and input the created labels. The reason we are creating a taxonomy is because we will use it as a reference key when sorting our portfolio with Quicksand.

Now that all of our custom post type is complete along with the correct formatting and our own taxonomy, we need to finally initialise all of our code so that it will be displayed in the admin. Let’s begin by adding the following code at the bottom of our file:

add_action( 'init', 'post_type' );
add_action( 'init', 'portfolio_filter', 0 );
add_filter( 'post_updated_messages', 'portfolio_messages' );

Once we have input this, we then need to open our functions.php file and insert the following line of code:

include("portfolio/portfolio-post-types.php");

We need to include our custom portfolio type into our functions.php file for the script to run when the functions of your WordPress theme are being called. Now you will see in your admin panel a section titled Portfolio with 3 sub-navigation items called “Portfolio”, “Add Item”, and “Filter”.


Step 2 Create Portfolio Page

Now we have our entire portfolio settings complete, we need to output our portfolio items. We begin this by creating a new PHP file called portfolio.php. Firstly let’s add some of the essentials for the creation of a page template:

<?php /* Template Name: Portfolio */ ?>

	<?php get_header(); ?>
	
	<!-- #content  BEGIN  -->
	<div  id="content" class="clearfix">
	
		// We will add  our content later 
		
	</div><!-- #content  END -->
	
<?php  get_footer(); ?>

Now, we have our fundamental page template created we need to populate our portfolio. We need to create a page first which will act as our Portfolio page, so head to the Pages -> Add New in our Dashboard. On the right hand side, you will see a box titled Page Attributes with a drop down of Default Template, select the desired template you would like to use in our case portfolio should be selected and then select publish.

Display the Filter

Now, let’s go back to editing our Portfolio page template and begin to insert the filter for our portfolio. First, we begin by wrapping the filter within an unordered list and each of the categories will be an element in our list.

<ul class="filter clearfix">

	<li><strong>Filter:</strong></li>
	<li class="active"><a href="javascript:void(0)" class="all">All</a></li>

</ul>

Let’s add some PHP to our filter to automatically generate the filter categories that are being used within our portfolio.

<?php
	$terms = get_terms('filter', $args);
	$count = count($terms); 
	$i=0;
	if ($count > 0) {
		foreach ($terms  as $term) {
		$i++;
		$term_list  .= '<li><a href="javascript:void(0)" class="'.  $term->slug .'">' . $term->name . '</a></li>';
		
			if ($count  != $i)
			{
				$term_list .= '';
			}
			else
			{
				$term_list .= '';
			}
		}
		echo $term_list;
	}
?>

What we are doing here is first initialising the taxonomy we wish to get, in our case filter. Secondly, set up a count with our categories for us to increment over each element within our filter, and then apply a conditional statement to check if the count that we have set is less than 0; meaning that if there are no categories in the filter or no categories assigned to a portfolio item, nothing will be output. If there are categories in our filter then we want to alter the output for each element.

We do this by the following line within our segment of code:

$term_list .= '<li><a  href="javascript:void(0)" class="'. $term->slug .'">' . $term->name . '</a></li>';

We are creating a list element to fit within our unordered list, and then setting the “href” to a blank target because Quicksand will handle the organising of content, then we set our class name to the slug of the portfolio item for consistent referencing, and finally outputting the name of the category within our filters.

Display the Portfolio Items

Brilliant, we now have a dynamic filter implemented. Now we are going to output our portfolio items. Let’s begin querying our database in order to get all the posts for the portfolio post type and set up our WordPress Loop. We begin by setting up a new WP_Query object and pass the correct parameters to it.

<?php
	$wpbp = new WP_Query(array(
			'post_type' =>  'portfolio',
			'posts_per_page'  =>'-1'
		)
	);
?>

We assign our WP_Query object to a variable so we can reference our query when we are initialising our Loop. We set our post type to portfolio so we only query our custom post type which we created earlier and finally set the posts_per_page to -1. We use -1 so that there are no fixed limitations to the amount of posts per page, therefore displaying all portfolio items, if we wanted we could also enter any number and it would only display the amount of portfolio items which was entered here.

Now that we have a query object which we can reference, let’s set up our Loop to output our portfolio items. We begin by inserting the following code:

<?php if ($wpbp->have_posts()) : while  ($wpbp->have_posts()) : $wpbp->the_post(); ?>

	<?php // All of our portfolio content will be inserted in  here... ?>
	
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>

Before we begin entering content into our loop, we are going to set up our featured images. Open up your functions.php file and we will add some custom featured image sizes to be output for each portfolio item.

Let’s check first if the current version of WordPress handles the featured image functionality, and then set up some general settings for it to work correctly. We add support for the post-thumbnails and set a default size of 56px by 56px.

if ( function_exists( 'add_theme_support' ) ) 
{
	add_theme_support(  'post-thumbnails' );
	set_post_thumbnail_size(  56, 56, true );
}

Then we want to add our own custom thumbnail sizing. Insert the following code on a line below: set_post_thumbnail_size

add_image_size( 'portfolio', 295, 150, true );

This method allows you to create your own thumbnail size by first setting the reference name for the thumbnail, then the width and height and finally if the thumbnail should hard crop the image to fit the size specified. You can alter the sizes of your featured image to fit with your layout; with the purpose of this tutorial I have a 3 column grid layout.

Now that we have our Featured Image set up, we are going to head back to our portfolio page template and output the portfolio item featured image.

As the organisation for each portfolio item is best handled by an unordered list, we will first create one and then output our featured image which we have just setup. Insert the following code inside your WordPress Loop:

<ul class="filterable-grid clearfix">
	<li>
	
		<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) :  ?>
		
			<?php  the_post_thumbnail('portfolio'); ?>
			
		<?php endif;  ?>
		
		<p><a  href="<?php the_permalink(); ?>"><?php echo  get_the_title(); ?></a></p>
		
	</li>
</ul>

We initially check if the theme supports the thumbnail function. If the theme supports this feature then it will output the feature image at the dedicated thumbnail we have specified earlier. After outputting our featured image, we then output the title of the Portfolio item directly below the image.

Connect Portfolio Items & Filter

We need to tweak the different elements of each portfolio list item to ensure that the referencing for each portfolio is correct to the categories the item is assigned to. For this, we will first need to get the categories from our taxonomy. Insert the following code within your Loop:

<?php $terms = get_the_terms( get_the_ID(), 'filter' ); ?>

Next, we are going to add some attributes to our list element (li). We begin by adding a data-id to our list item, to provide a unique identity to each of the portfolio items. We are also going to add a data-type; this will act as our referencing to our filter. Let’s replace our opening list element (li) with the following code:

<li data-id="id-<?php echo $count; ?>"  data-type="<?php foreach ($terms as $term) { echo  strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">

We apply a count to our data-id, and when looping through each item, the count will be increased (we will add the count shortly). We then loop over each category in our taxonomy and apply a regular expression to find the spaces and replace it with a “-” to match the slug of the category and then finally put a blank space at the end, so we are able to apply more than one category to a portfolio item.

Finally, we are going to ensure that we increment our count and provide a unique reference to each of our portfolio items. We need to add the following code just before we end the loop:

<?php $count++; ?>

Final Code for Displaying Portfolio

<ul class="filterable-grid clearfix">

	<?php $wpbp = new WP_Query(array(  'post_type' => 'portfolio', 'posts_per_page' =>'-1' ) ); ?>

	<?php if ($wpbp->have_posts()) :  while ($wpbp->have_posts()) : $wpbp->the_post(); ?>

	<?php $terms = get_the_terms(  get_the_ID(), 'filter' ); ?>

		<li data-id="id-<?php echo  $count; ?>" data-type="<?php foreach ($terms as $term) { echo  strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">
	
			<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) :  ?>
			
				<?php  the_post_thumbnail('portfolio'); ?>
			
			<?php endif; ?>
		
			<p><a href="<?php the_permalink(); ?>"><?php echo get_the_title();  ?></a></p>
	
		</li>

	<?php $count++; ?>
	<?php endwhile; endif; ?>
	<?php wp_reset_query(); ?>

</ul>

Step 3 jQuery & Quicksand

We’re making progress now, but before we continue we need to go and download some jQuery scripts. We need to download the following scripts:

We also need to create a JavaScript file to handle all of our custom jQuery that we will be writing shortly. So let’s create a blank JavaScript file called jquery.custom.js. Now that we have all of our essential scripts, let’s open our functions.php and create a blank function called register_js. Once we have our blank function, we are going to insert our scripts using the wp_register_script and wp_enqueue_script methods. First, we must check that we’re not in the admin to ensure the scripts are only loaded on the front end. Insert the following code into our function:

// Register our scripts
function register_js()
{
	if ( !is_admin() )
	{
		wp_register_script( 'quicksand', get_template_directory_uri() . '/js/jquery.quicksand.js', 'jquery' );

		wp_register_script( 'easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', 'jquery' );

		wp_register_script( 'custom', get_template_directory_uri() . '/js/jquery.custom.js', 'jquery', '1.0', true );

		wp_enqueue_script( 'jquery' );
		wp_enqueue_script( 'quicksand' );
		wp_enqueue_script( 'easing' );
		wp_enqueue_script( 'custom' );
	}
}

First with wp_register_script we specify a handle as our first argument for reference when enqueuing the scripts, then add the source link to the script as our second argument (this applies to each registration of a script). We also specify jquery as a dependency to load WordPress’ included version of jQuery when we enqueue the script.

Once we have registered all of our scripts, we then enqueue them by using wp_enqueue_script. We pass all the handles that we used when registering as a reference to enqueue our scripts. Finally, we need to initialise our function by adding the following code in our functions.php file:

add_action('init', 'register_js');

Writing Quicksand

Now that we have all of our scripts in place, we can begin writing our jQuery custom script for the handling of Quicksand. Let’s open up our jquery.custom.js script and let’s set up the environment by inserting the following code:

jQuery(document).ready(function() {

	// We will insert our quicksand script in here

}); // END OF DOCUMENT

Now we have our script structure, we will create a function called portfolio_quicksand and only execute if the Quicksand plugin exists.

function portfolio_quicksand() {

	// All of our quicksand handling will happen in this function

}

if(jQuery().quicksand) {

	portfolio_quicksand();

}

I will break down the following into smaller steps for you to understand all that is taking place when creating a Quicksand portfolio. Let’s begin by setting up our variables. Insert the following code into our portfolio_quicksand function:

var $filter;
var $container;
var $containerClone;
var $filterLink;
var $filteredItems;

We will be using these variables more frequently, so it’s always a good way to get a solid foundation of variables set up. Next we are going to assign our variables:

$filter = $('.filter li.active a').attr('class');
$filterLink = $('.filter li a');
$container = $('ul.filterable-grid');
$containerClone = $container.clone();

We first set up our filter to the unordered list class from our portfolio page template. Secondly, we set up a filterLink; this will act as our clicked item within our filter. Then we need to assign our container of our portfolio items, and finally we require a cloned version of our container, to manipulate the data with Quicksand.

Next, we are going to write our click function, so when a user selects a category the container should be manipulated and the output of the content should display. Let’s start by calling a click function on our filterLink:

$filterLink.click(function(e) {

	// We will add the content for this function now...	

});

Now let’s handle the active state of the list element. We begin by first removing any class with a current active state, then searching through the filter and splitting the filter into separate items, and finally applying an active class to the clicked item (category):

	$('.filter li').removeClass('active');
	
	$filter = $(this).attr('class').split(' ');
			
	$(this).parent().addClass('active');

This will help when styling your filter, because you will be able to provide active states for when a user has selected a category.

Moving on, we will handle a condition for the filtering of our data. We begin by first checking if all has been selected. If all has been selected then display all the elements within our container, else display the items within the container which has been selected by the filter.

Previously, when we were creating our portfolio page template and we assigned a data-type to each of our portfolio items, this is where we will be using it as a reference key to find our selected data.

	if ($filter == 'all') {
		$filteredItems = $containerClone.find('li'); 
	}
	else {
		$filteredItems = $containerClone.find('li[data-type~=' + $filter + ']'); 
	}

Finally, we call the Quicksand method, and pass our filteredItems and all of our animation options:

	$container.quicksand($filteredItems, 
	{
		duration: 750,
		easing: 'easeInOutCirc',
		adjustHeight: 'dynamic' 
	});

Final Code for Our Quicksand

function portfolio_quicksand() {
	
	// Setting up our variables
	var $filter;
	var $container;
	var $containerClone;
	var $filterLink;
	var $filteredItems
	
	// Set our filter
	$filter = $('.filter li.active a').attr('class');
	
	// Set our filter link
	$filterLink = $('.filter li a');
	
	// Set our container
	$container = $('ul.filterable-grid');
	
	// Clone our container
	$containerClone = $container.clone();
 
	// Apply our Quicksand to work on a click function
	// for each of the filter li link elements
	$filterLink.click(function(e) 
	{
		// Remove the active class
		$('.filter li').removeClass('active');
		
		// Split each of the filter elements and override our filter
		$filter = $(this).attr('class').split(' ');
		
		// Apply the 'active' class to the clicked link
		$(this).parent().addClass('active');
		
		// If 'all' is selected, display all elements
		// else output all items referenced by the data-type
		if ($filter == 'all') {
			$filteredItems = $containerClone.find('li'); 
		}
		else {
			$filteredItems = $containerClone.find('li[data-type~=' + $filter + ']'); 
		}
		
		// Finally call the Quicksand function
		$container.quicksand($filteredItems, 
		{
			// The duration for the animation
			duration: 750,
			// The easing effect when animating
			easing: 'easeInOutCirc',
			// Height adjustment set to dynamic
			adjustHeight: 'dynamic' 
		});
	});
}

Step 4 Lightbox Integration (Additional Extra)

Amazing right, you should now have a fully functionally Quicksand portfolio, but let’s not stop just there. I’m going to put an additional extra, this is totally optional but it could become a favourite feature, and that’s Lightbox. We will be using the jQuery plugin called PrettyPhoto for our Lightbox integration.

First thing we are going to do is download the PrettyPhoto plugin.

Once we have downloaded our PrettyPhoto files, we will first copy over the PrettyPhoto images, which will be in the images folder and then you need to copy the folder titled PrettyPhoto into our theme. We also need to copy over the CSS and PrettyPhoto’s JavaScript file, so let’s copy them over to the appropriate folders in our theme.

Now that we have all of our files in place, we need to initialise them within our theme. Within our functions.php file, we will create another function to handle our styles and we will call this function register_css. Then we will register our styles and enqueue our styles, thus insert the following code into your functions.php file:

// Register our styles
function register_css()
{
	if (!is_admin()) {
		wp_register_style( 'prettyPhoto', get_template_directory_uri() . '/css/prettyPhoto.css' );
		wp_enqueue_style( 'prettyPhoto' );
	}
}

add_action( 'init', 'register_css' );

We have all of our files in place and they are being initialised by our theme. Now we need to make use of this and implement Lightbox into our theme. Let’s open up our portfolio.php (portfolio page template) and add some code to our Featured Image.

First, we need to get a large image of the featured image which has been set. This will then act as the fullsize image when the user clicks on the image and PrettyPhoto loads. Inside our WordPress Loop, we need to insert the following code:

<?php
	$large_image = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'fullsize', false, '' );
	$large_image = $large_image[0];
?>

The code we have inserted will find the current post within the loop and find the original source of the image and then find the fullsize version of the image. Once we have returned our full size image, we will force the image to be stored in the array index of 0. This is used for no overrides or duplicates with our full size images.

Once we have our full size image accessible, we will now initialise PrettyPhoto on our featured image. The following code will link the fullsize image to the featured image of the portfolio item and pass the reference to PrettyPhoto, replace the code where you created your featured image with the following:

<a rel="prettyPhoto" href="<?php  echo $large_image ?>"><?php the_post_thumbnail('portfolio');  ?></a>

Great, we have got all of our files and scripts in place, we have got the full size image for our featured image and we have referenced our featured image to our full-size image with PrettyPhoto. Next, we need to write our JavaScript to make the Lightbox appear and work.

Let’s head back to our jquery.custom.js file and create another blank function to handle our PrettyPhoto:

function lightbox() {

	// Our Lightbox functioning will be added now...

}

if(jQuery().prettyPhoto) {
	lightbox();
}

Now that we have our function, we will initialise PrettyPhoto. We do this by adding the following code within our Lightbox function:

jQuery("a[rel^='prettyPhoto']").prettyPhoto({
	animationSpeed:'fast',
	slideshow:5000,
	theme:'pp_default',
	show_title:false,
	overlay_gallery: false,
	social_tools: false
});

You can read the full documentation of all the parameters that PrettyPhoto will accept in the use of the plugin at: PrettyPhoto jQuery Lightbox Clone

So, it’s all done! Lightbox implementation into your WordPress theme, but wait let me guess when you click on the filter and use Quicksand; the Lightbox is no longer working. That’s because we need to alter our Quicksand script and pass one more small piece of code to make sure that Lightbox works even when we filter through our portfolio.

So let’s fix this small problem by adding the following script to our portfolio_quicksand function within our jquery.custom.js file:

$container.quicksand($filteredItems, 
	function () { lightbox(); }
);

What we do here is call the Quicksand plugin once more and pass a function within this call to our Lightbox function. So every time Quicksand filters the content, the Lightbox function is called applying the PrettyPhoto to each image.


Step 5 Pagination Integration (Additional Extra)

Many people love having the use of Quicksand, but some people like the use of both Quicksand and pagination within their portfolios. This is another additional extra to create pagination within your portfolio. I will be using the WordPress plugin: WP_PageNavi.

Let’s first install and activate the plugin. Head to the Plugins -> Add New page in our admin section and search WP_PageNavi, once found click Install Now and Activate Plugin once installed.

Now that we have our plugin setup, let’s open up our portfolio page template and make some modifications to our file.

First, we need to setup our page to allow pagination. We do this by inserting the following segment of code before we query our database:

$paged = get_query_var('paged') ? get_query_var('paged') : 1;

Once we have our pagination initialised, we need to modify the database query. We change the post_per_page to a number to display a maximum number of posts which will be displayed on each page. Then we pass a new parameter to our query paged and reference this to our code segment which allowed us to paginate the page, as the following code demonstrates:

$wpbp = new WP_Query(array( 'post_type' => 'portfolio', 'posts_per_page' =>'2', 'paged' => $paged ) );

Great, we have a portfolio with pagination. We just need some controls to help us with the navigation of each page. The following code checks if the WP_PageNavi plugin is installed and then initialises the wp_pagenavi with the query of the database passed as a parameter. We then reset our postdata and all content is correctly paginated.

<?php
	if(function_exists('wp_pagenavi'))
	{
		wp_pagenavi(array(  'query' => $wpbp ) );
		wp_reset_postdata();
	}
?>

That’s it! You will have a fully functional portfolio with Quicksand, Lightbox and Pagination.


Conclusion

Give yourself a pat on the back! You have successfully created a Quicksand portfolio with WordPress. All the hard work is done and you can implement it with any work you develop.

I would like to say a HUGE thank you for spending the time to read my tutorial, I hope it helped. Please feel free to leave comments and I will try my best to assist and answer them.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Paul

    Nice read – this is actually much much easier and better with jQuery Isotope (http://isotope.metafizzy.co/)

    • http://www.lukespoor.com Luke

      Isotape cannot be used in commercial projects without purchasing a license whereas Quicksand can ;-)

      Thank you very much much for the tutorial, I’ve been waiting! :)

      • Paul

        A one time purchase of $25 making it usable for all future projects – a fairly insignificant cost for such a great tool!

        All the jQuery needed to get Isotope to filter a group is $(‘#container’).isotope({ filter: ‘.foo’ });

        Isotope also features progressive enhancement on animations, multiple automatic layout modes, and works well with infinite scroll!

        I managed to set up Isotope on my latest WordPress project in no time and very very minimal code in a very short amount of time.

        • https://twitter.com/VinnySinghUK Vinny

          I do agree with using Isotope being an easier solution, and the commercial price factor may be off putting to some developers. But I wanted to provide a tutorial where the implementation of Quicksand would be a easy as the Plugin itself is difficult to implement for some people.

          • http://kreativeko.com Menj

            the demo link is not working anymore :(

  • Pingback: Create a Quicksand Portfolio With WordPress | Shadowtek | Hosting and Design Solutions

  • http://themeforest.net/user/JamiGibbs Jami Gibbs

    Great work, Vinny!! This article is going to be a top 10 hit in short order.

  • http://www.jguiss.com Julien

    WOW i was looking for this since a long time ! I made my portfolio without quicksand… but with your help i think i’ll try implement it again :)

  • http://www.customicondesign.com/ custom icon design

    Good article, I just want to know why you dont show the live demo on the web. In face I want to see the effect before we read the article. Many thanks.

  • http://www.fangirlconfessions.com Robin Burks

    I will have to reiterate the above comment. Why isn’t there a demo included?

  • http://vermeertech.nl/ Rob Vermeer

    Hi Vinny,

    Nice tutorial about a great script (quicksand). I’ve got a couple of questions/suggestions though.

    Why not use a post-type archive template (archive-portfolio.php)? http://codex.wordpress.org/Post_Types#Archive_template

    Also your loop is preferably used with query_posts (as it is your main loop). If you use the post-type archive template you can do:

    global $query_string;
    query_posts($query_string . “&posts_per_page=-1″);

    • http://www.VinnySingh.com Vinny

      I have considered this method but I created this Tutorial on the bases that Developers would provide this in a Theme Development for non-experienced users / customers and having a dedicated section to handle their portfolio would be the easiest solution for them.

  • http://zslabs.com Zach

    Excellent tutorial – great usage of best-practices properly commented code. Thanks!

  • http://www.techna2.com/blog Neerav

    Very good tutorial!! I did try Quicksand before but never able to get it work, now its working right in front of me just because of this Tutorial. Thanks!

  • http://danielcgold.com Dan

    Thanks for this tutorial! Do you have a demo page?

  • Kenton

    Great Tutorial!! Always looking for an easy guide with using Quicksand! Thanks

  • http://ivomynttinen.com/ Ivo Mynttinen

    Good one, I’ve developed my Portfolio with WordPress + Quicksand as well but with some different techniques. Working example can be found on my site: http://ivomynttinen.com/category/work/

    • http://www.stickersadv.com ahmed mokhtar

      hello that’s a good job really perfect and so nice would u please send me this them it’s won’t work with me as i want

    • Carlos

      Smooth! Would love to see your “different techniques” You should post your code!

  • http://www.paulund.co.uk Paul

    Great tutorial I’ll be doing that tomorrow.

  • Roberto

    Very interesting tutorial. I think I found a bug in the jquery.custom.js though. The settings for quicksand are not being respected. I tried changing the duration setting for instance but no change occurs on the front-end. Instead the plugin’s defaults are being used.

    • Azhari Subroto

      Yeah… I think that too…
      The duration another function doesnt work properly…
      anyone can fix this?

      • Azhari Subroto

        Now, It’s works fine. Just little change:

        /*———————————————————————————–

        Custom JS – All front-end jQuery

        ———————————————————————————–*/

        jQuery(document).ready(function() {

        function portfolio_quicksand() {

        // Setting Up Our Variables
        var $filter;
        var $container;
        var $containerClone;
        var $filterLink;
        var $filteredItems

        // Set Our Filter
        $filter = $(‘.filter li.active a’).attr(‘class’);

        // Set Our Filter Link
        $filterLink = $(‘.filter li a’);

        // Set Our Container
        $container = $(‘ul.filterable-grid’);

        // Clone Our Container
        $containerClone = $container.clone();

        // Apply our Quicksand to work on a click function
        // for each for the filter li link elements
        $filterLink.click(function(e)
        {
        // Remove the active class
        $(‘.filter li’).removeClass(‘active’);

        // Split each of the filter elements and override our filter
        $filter = $(this).attr(‘class’).split(‘ ‘);

        // Apply the ‘active’ class to the clicked link
        $(this).parent().addClass(‘active’);

        // If ‘all’ is selected, display all elements
        // else output all items referenced to the data-type
        if ($filter == ‘all’) {
        $filteredItems = $containerClone.find(‘li’);
        }
        else {
        $filteredItems = $containerClone.find(‘li[data-type~=' + $filter + ']‘);
        }

        // Finally call the Quicksand function
        $container.quicksand($filteredItems,
        {
        // The Duration for animation
        duration: 400,
        // the easing effect when animation
        easing: ‘easeInOutCirc’,
        // height adjustment becomes dynamic
        adjustHeight: ‘dynamic’
        }, function (){
        $(“#Gallery a.klikdong”).photoSwipe({ enableMouseWheel: false , enableKeyboard: true });
        });

        //Initalize our PrettyPhoto Script When Filtered

        });
        }

        if(jQuery().quicksand) {
        portfolio_quicksand();
        }

        function lightbox() {
        // Apply PrettyPhoto to find the relation with our portfolio item
        $(“#Gallery a.klikdong”).photoSwipe({ enableMouseWheel: false , enableKeyboard: true });
        }

        if(jQuery().photoSwipe) {
        lightbox();
        }

        }); // END OF DOCUMENT

  • http://wp.envato.com/ Japh Thomson
    Staff

    Due to popular demand, Vinny and I have updated the tutorial to now include a demo! You can find the demo link at the top of the tutorial.

    Thanks for reading! :)

  • http://www.VinnySingh.com Vinny

    Thanks for all the kind words everyone! I hope you enjoyed the Tutorial.

    All that requested for a Demo Site…it is now available…Check out how your portfolio will look with the following of this tutorial =)

    • http://kreativeko.com Menj

      Thank you so much for this great tutorial and demo as well! Big help in my upcoming project :)

  • Pingback: New WordPress Plugin Locks Down Your Website’s Security | Open Knowledge

  • Sébastien | French WordpressDesigner

    Just one problem, the pagination doesn’t work…

    When you click on a category, the page should correspond only to this category. So if the category “sketches” has three pages of items, there are three pages in pagination.
    And if you click to see page 2, we should actually see page 2 of the category “sketches”.

    I have seen anywhere offering this code system which seems, however logic.

    • http://madebyraygun.com Dalton

      Sébastien is right – the sorting and the pagination are completely unrelated here, so that feature is kind of useless. If you click on “sketches”, it should bring up all of the items in the “sketches” category, not just the items that are on the current page. The pagination should update as well to only include items in the “sketches” category. This is a great idea but unfinished.

  • Pingback: Tweet-Parade (no.8 FEB 2012) | gonzoblog.nl

  • BC

    Thanks for the tutorial Vinny!
    How would you go about setting this up to remove the ‘All’ option so that it just displays the categories and there is no option to display all items?

    Would this be possible to do?

  • http://niallm1.com Niall

    Cool stuff! I’ve been waiting for someone to do this for a while.

  • http://www.tristarwebdesign.co.uk/ Paul Weston

    I am very new to WordPress and have just started to use it for my design projects. At the moment I am just using it for news feeds but I will be using it more and more in the coming months. This is why I am spending time looking at tutorials like this one so it can give me an insight and guide to how I can create certain things in WordPress. I thought this tutorial had great detail and great comments to go along with it. This is a tutorial I will be spending time going through and will be a great help in me understanding what WordPress can do for me.

  • Gabriel

    Just great.
    Thanks

  • Maximo Saturnino

    Great stuff you got here Vinny! I just hope it works too on this website I’m doing. I always encounter this error: [Break On This Error] $filter = $(‘.filter li.active a’).attr(‘class’);
    I’m a noob in jQuery that’s why I can’t figure this thing out.

  • Pingback: Tweet Heat - The hottest Tweets of the Month [Feb 2012] | Inspired Magazine

  • Pingback: Best of WordPress in February 2012 | WP Theme Power

  • corey

    any thoughts as to what would prevent pretty photo from working? It didn’t work in my theme nor in the supplied download test theme

    • corey

      I’m getting this error in the js console “Uncaught TypeError: Property ‘$’ of object [object DOMWindow] is not a function line 19 in custom.js”

      • Nick

        i had that error too. update the version of jquery that your theme is using, and it goes away. get the latest version from google repository.

      • http://wp.envato.com/ Japh Thomson
        Staff

        Hi Corey, can you please try changing the line:

        jQuery(document).ready(function() {
        

        To this instead:

        jQuery(document).ready(function($) {
        

        Let us know if that fixes the issue for you! :)

    • http://www.twitter.com/vinnysinghuk Vinny

      Hello Corey,

      I haven’t experienced that problem and I can’t seem to find the reason why. Ensure that your lightbox (prettyPhoto) is in its own function and that you are calling it correctly. There shouldn’t be any problems with the Lightbox. I’m sorry I can’t help further.

  • Pingback: Tweet Heat – The hottest Tweets of the Month [Feb 2012] | CS5 Design

  • http://www.twitter.com/ryanmk Ryan

    Love this tutorial…Very easy and simple steps…Worked fine on my website, no problems! Thanks Vinny!!

  • Ilija

    This is an awesome tutorial, thank you Vinny.

    But one problem exists – WP displays a warning if an item doesn’t belong to any category.

  • http://codeforest.net Codeforest

    Hi, nice tutorial.

    As for the best practices, not really.

    For example, you named your function post_type(). What if you have multiple custom post types?

    It is considered to name the functions as descriptive as possible, for example portfolio_post_type.

  • Rupesh

    thanks for this page.
    i deployed it fine and could see the images and caption, but when i click on the caption’s link (/?portfolio=informational-web-style), it opens the home page. Am i missing anything.

  • Oleg

    Hi.
    Excellent tutorial, thank you.
    But there is one problem – Portfolio filter does not understand the Cyrillic font.
    How to solve the problem?
    Sorry bad English…

  • Oleg

    And Step 5 don’t work too…((

  • http://cleenmedia.com Aron

    Brilliant. I’ve implemented a filter system into our site but nothing near as efficient as yours. Great stuff, thanks!

  • http://miedema.co.za Steve

    Thanks for the tut.

    It would also be great to create a portfolio on WordPress using Isotope jquery plugin?

  • http://www.quirksmode.co.uk/ Quirksmode

    Great tutorial, just what I was after though is there any chance on expanding upon the Page Navi. It is currently fixed to 2 pages, but is there a way of this dynamically changing based on the filter choice?

  • http://virtuavillage.com Alex

    Nice tut. But i have a Notice with the WP Debug enabled:

    Notice: Undefined variable: args in /Users/alex/Projects/WEB DESIGN/WORDPRESS TESTS/FINAL/wp-content/themes/QuicksandTheme/portfolio.php on line 15

    Any way to fix this?
    Thanks

  • corey

    after literally days and days of pulling my hair out to get this to work I finally found my error. It doesn’t like when you change the slugs of the filters.

  • Marcin

    I have the same problem as Alex:

    When Wp Debug is enabled:

    Notice: Undefined variable: args in …. portfolio.php

    There is no declaration of this variable in portfolio.php. Where did You get that variable from?

    Thanks

  • http://www.seopatch.com viv .p

    Hi vinny Thanks for the nice post. its something similar to the post By Sumit Dave http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/comment-page-1/#comment-402624

    I have tried both way, but I still have trouble with Page-Attribute Box.Even after adding ‘page-attribute’ to Support alias I can’t getting Template section in the ‘page-attribute’ box. Also box heading ‘Attribute’ instead of ‘Page Attribute’. Give me the solution article. where u can teach us how to add Different page Layout via Layout Section.

  • corey

    Anyone per chance have any ideas as to why some of the filters aren’t working on my site. None of them are empty. The “websites” ones has at least 8 tags. http://theseniorpartners.com/portfolio/

    • http://www.billchambersdesign.com Bill Chambers

      Hey Corey, your menu is overlapping the filter nav. in your style sheet look for the contentwrap div and change top: 0; to top: 25px; and that should fix it.

      #contentwrap {
      left:0;
      padding-bottom:20px;
      position:relative;
      top:25px;
      }

  • Rodrigo

    Hey, thanks for your tutorial, it helped me a lot. :)
    But i have a single question, hope you have the time to answer me.
    How can i erase the instances of quicksand plugin from the page without leaving the HTML page? i made a button “Clear” that has no tags at all, and that made what i want, but there must be a better and cleaner way, maybe erasing the clone?
    thanks.

  • Al

    Great tutorial, however noticed that if any of the portfolio items are not assigned a filter, WordPress throws an error/warning: Invalid argument supplied for foreach(). At least I think this the reason for it after testing.

    Seems to be regarding this line in portfolio.php

    <li data-id="id-” data-type=”name)). ‘ ‘; } ?>”>.

  • http://www.mojo-themes.com/user/rifki/ Rifki

    It’s getting error when you enable wp_debug, you should put global $post, $post_ID; on the first line on portfolio message function.

  • Alex

    Thank you for this tutorial- just what I was looking for. I do have a question, though..

    I hate to ask such a simple question, but how do I get my images to be shown on my portfolio page? Use featured images? Embed them in a post/page? I’ve tried everything I can think of and nothing works.

  • http://www.tewitt.com vaibhav

    I have created portfolio successfully,but having one trouble that is my last filtered category is showing empty even content of it’s displaying in “All” category. how to fix it?

  • http://www.twitter.com/vinnysinghuk Vinny

    Hey Guys,

    I haven’t had a chance to help everyone who may be experiencing problems. If you are having troubles and need help then please follow me on twitter and I’ll be able to help you: @vinnysinghuk

    Thanks :)

    • http://www.tewitt.com vaibhav

      Followed successfully! :tweet tweet :)

  • http://www.trzygiegrx.com Grzegorz

    Hi Vinny, great tut, but I have a question. How 2 display subpage 4 single item of portfolio? Image is linked 2 jpg, is linked 2 subpage but when I click on it > display white screen. Please help. I don’t have tweeter. Maybe FB?

  • https://twitter.com/VinnySinghUK Vinny

    @Grzegorz – Firstly, you should sign up to twitter…its a good move :)

    Secondly, to display a single page for your portfolio you need to create a PHP file called:

    single-.php

    Then code the output for this page and it should work

  • Stephen Medawar

    Is there a way to default to a filtered state on load? (As if someone had clicked on a filter)

  • http://tewitt.com viv .p

    Hi Vinny! My portfolio page is almost complete. I have Implemented another effect of slide up and slide down of Another div class containing Title of Image after Mouse hover on Image. But This effect is not working on initial portfolio page selection, and its works on portfolio page only after at least one selection on “Filter” navigation tab.

    my added line of codes are here:-

    $container.quicksand($filteredItems,
    function () { lightbox();hoverimage();
    });
    });

    function hoverimage(){

    jQuery(‘ul.filterable-grid li’).hover

    (function(){jQuery(this).children(‘.portfolio_title’).stop()
    .animate({“top”:”123px”,},500);},
    (function(){jQuery(this).children(‘.portfolio_title’).stop()
    .animate({“top”:”-35px”,},200);})
    );
    };

    And Please don’t say to follow me: already followed by @Neelmoney

  • Claudio

    Hi Vinny, I’m trying to set a default fallback image when there is no thumbnail image for any of the items. Thanks for any help.

  • http://mikon.us Mike

    Hey Vinny! Awesome stuff Man, got this running in about 15 minutes and it worked perfectly. Now to Style it and get it to match the new website.

    I saw one thing with working with your tutorial and the Source files you provided, where you called out ‘posts_per_page’ =>’-1′ on the tutorial, and the Demo has ‘posts_per_page’ =>’2′ set in the source.

    Not a huge deal, but just to help those people that download the source files and don’t realize why it only shows two images, or they don’t care to read the entire tutorial or know much PHP.

    Again, appreciate your hard work and this tutorial! Well worth the read!

    Regards,
    Mike

    • Ro

      Thanks.

  • http://www.seopatch.com Mike codey

    Thanks vinny for awesome post:)
    I want to add fading effect on Images on mouse-hover.I am trying it ,as i am not an expert of Jquery. Fading function is not giving an output directly after initial portfolio page selection.And its start working only after clicking on at -least one filter menu selection. This means quicksand function is get initiate only after filter tab click.Give me some guideline so i can add extra animation on it .

  • Sally

    I am developing a child template of TwentyEleven. I load your template in and it was working great. I added pages and a menu and things started going wrong. When I try and add a page or post the permalink does not show up in the admin page under the title of the post/page as it normally does. Also, when I press “publish” I get a big white screen.

    Originally everything was working great but the first thing that went wrong was when I clicked on an image in the filtered gallery prettyphoto did not open but instead the image detail displayed after the site on the same page – so the page would become huge. And under the detaill of the image I noticed the words play repeated 6 or 7 times.

    I had this wonderful code working and now after adding pages and a menu it’s gone haywire…any ideas please.

  • https://twitter.com/VinnySinghUK Vinny

    Hello Guys,

    Its very difficult to message everyone individual to provide support on this post as I do not check it regularly enough to provide you with feedback and a quick enough response.

    The best way to get in contact with me is by my twitter, please just message me through twitter @vinnysinghuk or go onto my website: http://www.VinnySingh.com and email me.

    I do apologise for this, but if you need help then its the best way to get in contact with me. I will help all people who are willing to make the effort to ask.

    I’m glad you guys liked the tutorial and I will be posting more up shortly.

    Thanks

    Vinny

  • Julian Souto

    My congratulations for the tutorial

    If I have the settings you selected for permanent links post name, pagination plugin not working properly. You know how I could fix this bug

    Thanks

  • http://www.littlesparkvt.com littlespark VT

    Awesome tutorial. I’m sure a lot of wordpress developers will be using this in their work. Good job!

  • Alex

    I wanted to try to tutorial but for some reasons I don’t have the “Page Attributes” panel on my page.

    I am using WP Version 3.3.2

  • garrett

    I’m now following you on twitter. I’m on a localhost or I would have filled in the link url.

    I followed the tutorial (I did not do the extra stuff like lightbox and pagination)

    I’m having issues getting my portfolio custom post type to use the portfolio template we made in the tutorial.

    I created the page and selected porfolio as my template but its still not syncing with the custom post type.

    If you could help that would be awesome I am doing this for a client. Thank you.

    Garrett Goeppinger

  • http://www.pixylabs.com Giuseppina

    Hi Vinny, thanks for this great tutorial, I have followed it but I can’ t figure out why it’s not working at all here:

    http://www.pixylabs.com/#portfol

    I have tried to remove every other js script, but the result is still the same. Any help, would be very appreciated.

    Thanks!

    • FxB

      I have the same problem, i can’t figure out how to make the active state to change when i click on a filter term.

      It seems you have a class of ‘alpha40or’ on all your li and not an only one ‘active’

  • http://www.nightocoder.com Rawaf

    Hi, thank you for this best tutorial about create portfolio by wordpress, I liked it but I have question :

    I want show gallery after click on thumbnail (multi images not single image) can you anyone help me ? or have idea about this ?

    thank you

  • julia

    Hello, great tutorial!

    This is working wonderfully and I was just wondering if anyone knows how to enable the hash setting with this quicksand filter so I can link directly to a single filtered portfolio, just like they do here: http://www.newmediacampaigns.com/portfolio#government-economic-development

    Any suggestions are greatly appreciated. Thanks!

  • Pingback: Essential WordPress theme development tutorials

  • Angel

    Great tutorial!!!

    I need to change the order of the taxonomy list on the menu, how i can do that¿?

  • http://pixelflop.blogspot.com Bryan

    The demo is dead.

  • http://build.collabdesigns.com Susan

    Im trying to do it with out the pretty photo and have it go right to the perm link of the post however it seem that either the perm links are incorrect or this post type is not out putting a page?
    How can I fix the post type?

  • selva

    The demo link in broken

  • Abdullah Shafiq

    Its not working any more even your source files please update them, Thanks

  • Daniel Veres

    Has anyone suggestion for pagination issue?

  • Anne

    Great tutorial! I’m trying to implement this one with the current theme I’m working on but I bumped into a problem. Every time I click the permalink, instead of going to a post page, it gives me a 404 page. I have single.php, page.php, category.php & archive.php but I don’t know what I missed.Other posts that aren’t included in the custom taxonomy ‘portfolio’ appears.

    Hope you can help me, thanks! (:

    • Peter

      Wonderful plugin!

      Any news on how to create a direct link from the gallery. I would like people to be able to enter a page when they click on one of the images. Just like Anne, I get to a 404 page. I have all single.php, page.php and all that.

      Just like this: http://www.newmediacampaigns.com/portfolio#non-profit

      Thank for the help!

      • Peter

        Got an answer directly from Vinny. In order to create a link to a page instead of a light box you simply need to insert the “” on the element you wish to link and create a page called single-portfolio.php. You will then need to code the page and style the way you want it. As for me, I also had to change the permalinks seetings to month and name for it to work!

        Thanks again!

      • Peter

        Got an answer directly from Vinny. In order to create a link to a page instead of a light box you simply need to insert the php the_permalink(); on the element you wish to link and create a page called single-portfolio.php. You will then need to code the page and style the way you want it. As for me, I also had to change the permalinks seetings to month and name for it to work!

        Thanks again!

    • megainfo

      You appearantly have to visit the “Permalinks” settings page in the admin panel whenever you’ve made changes in the post type registration code. WordPress needs to flush the permalinks settings :P.

  • http://www.apprs.com/noruw/portfolio/ Santosh

    I am always getting error while am creating new page from admin or updating any page. Saying

    Warning: Cannot modify header information – headers already sent by (output started at /home/apprs/public_html/noruw/wp-content/themes/twentyeleven/portfolio/portfolio-post-types.php:1) in /home/apprs/public_html/noruw/wp-includes/pluggable.php on line 881

    Whats wrong.
    Please guide me.

  • http://www.iamkreative.co.uk Kevin

    Great post, is there a way to filter the items so the active ones just have a color overlay whilst they all stay visible?

  • http://cmorales.es Cmorales

    Great post, it helped me a lot to implement quicksand in my website :)

    I’ve found a couple of things to improve, though:

    In your code, you first set the class of the filter links using slug:
    $term_list .= ‘<li><a href=”javascript:void(0)” class=”‘. $term->slug .’”>’ . $term->name . ‘</a></li>’;

    But later on the code, you set the data-type using the term name with a preg_replace:
    data-type=”<?php foreach ($terms as $term) { echo strtolower(preg_replace(‘/\s+/’, ‘-’, $term->name)). ‘ ‘; } ?>”>

    Why not use slug anyway? That way, especially with non-english languages, sometimes you won’t get the same string for both and, therefore, the filter will fail.

    I’d do it like this:
    data-type=”<?php foreach ($post_terms as $term) { echo $term->slug. ‘ ‘; } ?>”>

  • Cssmania

    I successfully created a portfolio but when i click on item it shows page not found. Can you tell me what is wrong.
    http://www.apprs.com/noruw/portfolio/

    • kenmcneill

      Very nice. Would you care to share how you included the category name below each item? Thanks!

  • Scott

    This code was just what I need. Thx. The only thing is it doesn’t out the right child term. I have custom taxonomy terms as so:
    Breadline (parent)
    - Artisan (child)
    - Loaves (child)
    - Rolls …
    - Subs ….
    Cakes (parent)
    - Layer Cakes (child)

    But the code gets outputted like below. All using the same child even though one is loaves and one is rolls. Why is this? Any help would be great! Thanks!

    My discription</p>
    </li>

    • Scott

      Got it working….don’t know what I did though.

  • Dave

    Im wondering how to do this – Instead of clicking on one of the filtered images and it popping up a thick box that scrolls through all the other images on the page, could it be made so that when you click on an image it pops a separate group of images. So the first images you see are only the thumbnail for their own group of images and the pretty box will scroll through the group of images attached to that thumbnail. So there are categories like dogs cats fish, and you clicked on dogs, you would see a picture of lets say a hound, bull dogs, beagles, etc. If you clicked on the hound dog picture, the thick box would pop up showing a group of hound dog pictures, not the other dog breeds on that page. I figure you would have to create a custom post type and somehow either uploaded multiple images with a thumbnail right into the post type or used a gallery plugin like nextgen and attached individual galleries to each post…. Any ideas on this ? Ive seen it done before somewhere.

  • http://www.birrwerk-studios.de Robin Birr

    Hello I have installed the portfolio. My question is, but how can I make it so that the items are displayed in the portfolio also on our front page with articles from the normal?

    Here the page with the Portfolio: http://heisler.birrwerk-studios.de/?page_id=1287

    Thanks for helping

  • Pingback: jQuery Tutorial collection | WoolyDeer

  • megainfo

    No worries, guys. Think I solved it.

    It’s about custom post types just show 404 page.

    You appearantly have to visit the “Permalinks” settings page in the admin panel whenever you’ve made changes in the post type registration code. WordPress needs to flush the permalinks settings :P.

  • Ryan

    Hi, I was wondering if there is a way to filter child categories of a parent rather than filtering a custom post type and categories? For example if the parent category is Portfolio and I have child categories such as Web Design, Illustration, logos, etc, is it possible to filter those posts?

    I was using your script and it worked great but I came to a road block because of my Nivo Slider plugin. With the slider there is no way to limit the number of posts/slides so I had been using sticky posts to have it only load the slides I wanted. Unfortunately sticky posts aren’t supported with custom post types. So I’m looking for an alternative method to sort my portfolio.

    I’m new to PHP, but I was able to get the navigation filter to load the child categories. Instead of creating a the portfolio page portfolio.php I created a category template called category-portfolio.php. I then changed this line:

    “$terms = get_terms(‘filter’, $args);” to “$terms = get_categories(‘child_of=’.get_query_var(‘cat’));”

    I’m not sure if I’m implemented this properly but it seems to have worked in displaying the child categories.

    Then to pull the posts from my Portfolio category I changed this line:

    ” ‘portfolio’, ‘posts_per_page’ =>’-1′ ) ); ?>” to ” ‘portfolio’, ‘posts_per_page’ =>’6′, ‘paged’ => $paged ) ); ?>”

    That’s as far as I can go, so far this works for displaying the child categories and the posts but it doesn’t filter the results, and I can’t for the life of me figure out how to get it working, or if it can even do what I want it to.

    Any help would be greatly appreciated!

    Thanks!
    Ryan

  • APrather

    Is there a way to replace Lightbox to cycle slideshow like this http://www.unleashed-technologies.com/demo/cycleexample/cycle.html?

    I tried this method, I end up getting conflict which force QS to stop function.

    Anyone?

  • http://www.smbmedia.co.uk Tom

    Great tutorial, thanks for sharing it with us, however I seem to have found a (perhaps minor) bug…

    I was using (for example): “category-one-name” as one of the category/ filter slugs.

    However when you try to filter on the front end, it pulls up a blank page. Only under the ‘all’ category do the items appear.

    After several hours I managed to work out why… category slugs must only be a single word… or at least, contain no hyphens (-).

    Does anyone have a fix for this?

    Thanks,
    Tom

    • Romain

      Do you succeed to fix it ? Because I have the same problem.

      Thanks

      • http://twitter.com/bryanlewis Bryan Lewis

        I’m also having the same problem. A fix would be amazing!

  • Pingback: 20 In Depth Tutorials To Build Your Own Portfolio | DesignWoop

  • Kenny

    Is it possible to use this solution on multiple page templates? I currently have it working on 2 separate templates but one of them isn’t picking up the duration/easing/adjustHeight settings…

  • Vatco

    Great tut, but who knows how to fix the pagination problem.When i have more than one filter cattegory only the first registered cattegory display the posts, when i click on another cattegory i need to be on the 3-rd page to see the posts.

  • alex rapz

    I have implemented mixed portfolio using images and videos, where videos items are loaded using metabox for youtube and vimeo links. Initially portfolio displays fine even quicksand animation is also working as usual. But videos item are fluctuating and try to loading on each event of filter click. they are not animated like images . how to fix this?

  • Denver

    Hey could someone help, for some reason the items are not filtering!

    http://22twenty.com/wordpress/artists

  • Carlos

    My portfolio is showing only 2 images, anybody knows why?(there’s 12 images added)

    • http://twitter.com/Viruthagiri Viruthagiri

      Install wp-pagenavi plugin or change posts_per_page parameter in this line $wpbp = new WP_Query(array( ‘post_type’ => ‘portfolio’, ‘posts_per_page’ =>’2′, ‘paged’ => $paged ) );

  • http://twitter.com/meteorBOB meteorBOB

    I just found this tutorial and tried the demo out in Firefox as well as Chrome. The filters are not working at all. I hate to go through this tutorial and have the end result not work. Any ideas?

    • http://twitter.com/jrmvii Jérémy V

      Seems to be related to Jquery newest version. It works if you deregister default WP jquery and downgrade to 1.7.2 in functions.php. I wish there was a cleaner way…

      function register_js()
      {
      if ( !is_admin() )
      {
      wp_deregister_script(‘jquery’);
      wp_register_script(‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js’);
      wp_register_script( ‘quicksand’, get_stylesheet_directory_uri() . ‘/js/jquery.quicksand.js’, array(‘jquery’),null,true );

      wp_register_script( ‘easing’, get_stylesheet_directory_uri() . ‘/js/jquery.easing.js’, ‘jquery’ );

      wp_register_script( ‘custom’, get_stylesheet_directory_uri() . ‘/js/jquery.custom.js’, ‘jquery’, ’1.0′, true );
      wp_enqueue_script(‘jquery’);
      wp_enqueue_script( ‘quicksand’ );
      wp_enqueue_script( ‘easing’ );
      wp_enqueue_script( ‘custom’ );
      }
      }
      add_action(‘init’, ‘register_js’);

  • Vinny Singh

    Dear All,

    Anyone who is experiencing issues with the plugin.

    Please follow these steps to ensure it will work once again:

    1. Open “functions.php”

    2. Copy All (RAW) from http://snippi.com/s/u3ea1i4

    3. Replace all content inside “functions.php” with updates content from Snippi

    Problem should be fixed.

    Regards,

  • Ken

    Shouldn’t unloading the wp core jquery with the new snippet below be avoided? http://wp.tutsplus.com/articles/how-to-include-javascript-and-css-in-your-wordpress-themes-and-plugins/

  • http://www.facebook.com/roneill1 Richard O’ Neill

    hi I have gone through this tutorial but final page is not working in that the post are going to a “page not found” and the filter isnt working.

    http://ramsgrangecommunityschool.ie/wp/links/

    any ideas what Im missing here?

    Thanks
    rich

    • http://www.facebook.com/roneill1 Richard O’ Neill

      fixed the link isuue by flushing the permalinks from reading thtough the comment but filter istself still broke

  • Pingback: How to develop a Wordpress Theme - WordPress Theme Development Tutorials

  • jake

    hi how would i got about making different portfolio templates, example 3 columns, 4 columns etc…

  • http://twitter.com/colthogh Colt Hogh

    Just finished this tutorial and got the following 3 errors popping up.

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘portfolio_filter’ not found or invalid function name in/Applications/XAMPP/xamppfiles/htdocs/AboutFace/wp-includes/plugin.php on line 406

    Warning: Cannot modify header information – headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/AboutFace/wp-includes/plugin.php:406) in /Applications/XAMPP/xamppfiles/htdocs/AboutFace/wp-includes/pluggable.php on line 876

    Warning: Cannot modify header information – headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/AboutFace/wp-includes/plugin.php:406) in /Applications/XAMPP/xamppfiles/htdocs/AboutFace/wp-includes/pluggable.php on line 876

    I have not touched anything inside of the wp_includes folder. Any ideas?
    Also the custom post not allowing me to add categories to the posts.

  • Pingback: Hyphens are causing a blank result - How-To Video

  • Pingback: Hyphens are causing a blank result | BlogoSfera