Friday Next is no longer taking new clients or performing work for existing clients.

If you’re using WordPress, you should be using custom post types.  They are extremely powerful, and they are what make WordPress the logical choice for any business’ website.  With custom post types, you can store an entire catalog of products, a database of recommended businesses, or anything else you can think of.

Once you’ve set up your custom post types (I highly suggest using the Custom Post Type UI plugin), you’ll want to actually access the post type and its taxonomies.  Let’s say you have a custom post type of ‘Media Players’ and you want to query all of the Sony devices.  Your custom post type would likely be set up something like this:

Media Players

  • Type
    • DVD Player
    • Blu-ray Player
    • Set Top Box
  • Brand
    • Sony
    • Panasonic
    • Toshiba
  • Cost
    • < $100
    • $100 – $200
    • > $200

You’ll be using the get_categories() function to find each of the individual brands of media players, and then you’ll use some simple PHP to weed out the ones you want.  Let’s take a look at the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
<!--?php 
   	$args = array(
      	'Brands' =&gt; 'Sony'
	);
	$query = new WP_Query( $args );
 
	while( $query-&gt;have_posts() ) : $query-&gt;the_post;
		the_title();
		echo '&lt;div class="entry-content"&gt;';
		the_content();
		echo '&lt;/div&gt;';
	endwhile;
?-->

What we’ve done here is created a new query that only checks posts with a taxonomy of ‘Brands’ with a value of ‘Sony’. Really gets to the point quickly! You can do whatever you want within your while loop, like store the data in an array, print it out, or shoot it to the moon.

Enjoy working with custom taxonomies!

Share This

Share this post with your friends!