I created one custom post type and two custom taxonomies.
register_post_type('blocks',array(
'labels' => array(
'name' => __( 'Blocks' ),
'singular_name' => __( 'Block' ),
'add_new_item' => 'Add New Block',
'edit_item' => 'Edit Block',
'new_item' => 'New Block',
'search_items' => 'Search Block',
'not_found' => 'No Block found',
'not_found_in_trash' => 'No Blocks found in trash',
),
'public' => true,
'hierarchical' => false,
'taxonomies' => array( 'section'),
'supports' => array('title','editor','thumbnail','custom-fields'),
'rewrite' => array('slug'=>'blocks','with_front'=>false),
));
register_taxonomy('location','blocks',array(
'hierarchical' => true,
'labels' => array(
'name' => __( 'Location' ),
'singular_name' => __( 'Location' ),
'add_new_item' => 'Add New Location',
'edit_item' => 'Edit Location',
'new_item' => 'New Location',
'search_items' => 'Search Location',
'not_found' => 'No Locations found',
'not_found_in_trash' => 'No Locations found in trash',
'all_items' => __( 'All Sections' ),
),
'query_var' => true,
'rewrite' => array( 'slug' => 'location' ),
));
register_taxonomy('section','blocks',array(
'hierarchical' => true,
'labels' => array(
'name' => __( 'Section' ),
'singular_name' => __( 'Section' ),
'add_new_item' => 'Add New Section',
'edit_item' => 'Edit Section',
'new_item' => 'New Section',
'search_items' => 'Search Section',
'not_found' => 'No Sections found',
'not_found_in_trash' => 'No Sections found in trash',
'all_items' => __( 'All Sections' ),
),
'query_var' => true,
'rewrite' => array( 'slug' => 'section' ),
));
I'm using the following to retrieve them:
<?php // Create and run custom loop
$custom_posts = new WP_Query();
$custom_posts->query('post_type=blocks&location=Front Page§ion=Profile');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>
<div class="block-1">
<?php the_post_thumbnail('large'); ?>
</div>
<?php endwhile; ?>
<?php // Create and run custom loop
$custom_posts = new WP_Query();
$custom_posts->query('post_type=blocks&location=Front Page§ion=Theme Left');
while ($custom_posts->have_posts()) : $custom_posts->the_post();
?>
<div class="float-left">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a>
<p><?php the_excerpt(); ?></p>
</div>
<?php endwhile; ?>
The problem is that any posts that has the custom taxonomy Location = Front Page appear in the first custom loop.
It shouldn't. The first custom loop should ONLY retrieve custom posts which has these two terms (from different taxonomies): Location = Front Page and Section = Profile.
(If only one term is missing the posts shouldn't be retrieved)
Any suggestions?