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?

link|improve this question

1  
Is what you want on your front page what appears here: jamesfishwick.com/skills/redesign ?? On your front page $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:08
No, what I want on my front page appears on my front page. I want my skills to be filtered, but they aren't.... – two7s_clash Aug 8 '11 at 13:09
1  
As Chris said, when you load the front page, both get_query_var('term') and get_query_var('taxonomy') will not be set, which is why you're not getting a filter on them. – t31os Aug 8 '11 at 15:22
@t3los - I'm not concerned with the front page really, I'm concerned with why trying to sort there, i.e. going to "jamesfishwick.com/skills/design/"; by selecting a skill or clicking on a skill link in a box, doesn't work. – two7s_clash Aug 8 '11 at 15:56
@t3los, @Chris - thanks, actually you helped me to see my stupid mistake, updating front-page instead of taxonomy – two7s_clash Aug 8 '11 at 16:03
feedback

2 Answers

In your call to register_taxonomy, instead of:

'rewrite' => true

Try

'rewrite' => array( 'slug' => 'skills' )

Make sure to update your permalinks as well.

link|improve this answer
Tried it, song remains the same... can you say more on updating permalinks? – two7s_clash Aug 8 '11 at 13:37
feedback

Duh, I had updated front-page.php when what I really needed to update was taxonomy.php to the same.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.