I'm trying to sort by a custom taxonomy on my front page here: http://www.jamesfishwick.com/
That is, a user can pick a skill from the "Works" menu and sort. Example: selecting/filtering by "jQuery" takes you to http://www.jamesfishwick.com/skills/jquery/ But no filtering is actually happening there.
The idea is to duplicate the structure of "/category/category_name" with "/skills/skill_name". But no actual filtering is happening, and I can't figure out why.
Here's front-page.php:
<?php get_header(); ?>
<?php
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
query_posts(array('post_type' => 'portfolio', 'skills' => $term->slug, 'posts_per_page' => -1));
?>
<?php get_template_part('loop-portfolio'); // Loop template for portfolio (loop-portfolio.php) ?>
<?php wp_reset_query(); ?>
<?php get_footer(); ?>
Here is my custom post/taxonomy setup:
add_action( 'init', 'register_my_taxonomies', 0 );
function register_my_taxonomies() {
register_taxonomy(
'skills',
'portfolio',
array(
'label' => __('Portfolio Categories'),
'singular_label' => __('Portfolio Category'),
'hierarchical' => true,
'query_var' => true,
'rewrite' => true,
'show_in_nav_menus' => true,
)
);
register_post_type(
'portfolio',
array(
'label' => __('Portfolio'),
'singular_label' => __('Work'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'query_var' => true,
'show_in_nav_menus' => true,
'menu_position' => 3,
'taxonomies' => array('portfolio'),
'supports' => array('title', 'editor', 'author', 'excerpt', 'page-attributes', 'thumbnail','custom-fields'),
'_builtin' => false, // It's a custom post type, not built in!
));
}
Any ideas on what is jamming me up?
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));probably wont work because your front page isn't receiving any query vars in the URL. On skills/redesign those query vars are filled in. – Chris Carson Aug 8 '11 at 4:08skillsto be filtered, but they aren't.... – two7s_clash Aug 8 '11 at 13:09get_query_var('term')andget_query_var('taxonomy')will not be set, which is why you're not getting a filter on them. – t31os Aug 8 '11 at 15:22front-pageinstead oftaxonomy– two7s_clash Aug 8 '11 at 16:03