Reputation: 101
Alright, so what I have is a Wordpress theme with a custom post type (listing) and custom taxonomies under that already built in. I've successfully added my own custom taxonomy (new-developments) under the existing custom post type.
I have also setup a custom template for the new taxonomy titled taxonomy-new-developments.php which functions as well, however, when attempting to get just those custom post types with the taxonomy "new-developments" displayed on their own pages I get all the posts with the custom post type "listing".
Here is my code:
customposttypes.php -
add_action('init', 'property_new_dev_taxonomies');
function property_new_dev_taxonomies() {
register_taxonomy('new-developments',
'listing',
array (
'labels' => array (
'name' => 'New Developments',
'singluar_name' => 'New Developments',
'search_items' => 'Search New Developments',
'popular_items' => 'Popular New Developments',
'all_items' => 'All New Developments',
'parent_item' => 'Parent New Development',
'parent_item_colon' => 'Parent New Development:',
'edit_item' => 'Edit New Development',
'update_item' => 'Update New Development',
'add_new_item' => 'Add New Development',
'new_item_name' => 'New Developments',
),
'hierarchical' => true,
'show_ui' => true,
'show_tagcloud' => true,
'rewrite' => array( 'slug' => 'new-developments'),
'query_var' => 'new-developments',
'public'=>true)
);
}
the call in my taxonomy-new-developments.php
<?php $posts = new WP_Query( array(
'post_type' => 'listing', 'new-developments'
)
); ?>
Any assistance in this matter would be greatly appreciated!
EDIT: something I left out, which is key to this issue is that the desired result is a page that displays the "new-developments" in a list (this works as you can see here )
Moving down the cascade of locations is where I have the problem, clicking on "Doral" which has one listing active brings up the problem page where all posts under the "listing" custom post type are displayed. This is what I need to figure out how to filter out to only display those under the "taxonomy" "location".
Upvotes: 0
Views: 4383
Reputation: 2101
try with this code:
<?php
$type = 'New Developments';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => -1,
'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() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
Or go through this link:
Custom Taxonomy Filtering with Wordpress
Thanks
Upvotes: 2