Hm… I think I’ve got mine working.
Sorry if it’s just stating the obvious, it wasn’t for me ?? Spent about 1 hour trying to figure out what I was doing wrong.
You should use a slug of taxonomy’s term (think slug of a category) as the value for registered taxonomy. I’ll reuse @hawken1 code for my example.
1) So you have your post type registered as “factory”.
2) Your taxonomy registered as “factorytype”:
$args = array(
"hierarchical" => true,
"label" => "Factory Types",
"singular_label" => "Factory Type",
//this is 'your_registered_taxonomy_name', here 'factorytype'
"rewrite" => array("slug" => "factorytype")
);
register_taxonomy("factoryType", array("factory"), $args);
3) You added some taxonomies terms for your “factory” type (similar as you add categories to a post). So use the slug of your created taxonomy term, not name, not id, but SLUG.
Say I created a taxonomy term (think category) with the name “Small factory” and slug “small-factory” for the “factory” post type.
So to get only factories of “Small factory” type, you’d use code as in @hawken1 example:
<?php
$args=array(
//'your_registered_taxonomy_name' => 'taxonomy_term_slug'
'factorytype' => 'small-factory',
'post_type' => 'factory',
'posts_per_page' => 10,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>