Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|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

closed as too localized by toscho Jul 9 '12 at 21:54

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

2 Answers

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

share|improve this answer

In your call to register_taxonomy, instead of:

'rewrite' => true

Try

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

Make sure to update your permalinks as well.

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

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