我无法解决这个问题。
我需要完成的工作: 在此页面上,我只需要显示在我的“新发展”自定义分类下标有“Doral”一词的项目的结果,这是自定义帖子类型“列表”的一部分。
目前,无论自定义帖子类型“列表”的术语或分类如何,该页面都显示所有项目。
我目前拥有的: 我的自定义分类法创建代码
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)
);
}
我的自定义分类模板 (taxonomy-new-developments.php)
<?php
/*
Template Name: Taxonomy New Developments
*/
?>
<?php get_header() ?>
<div id="columnswrapper" class="columns-1">
<?php get_sidebar(); ?>
<div id="content" class="norightsidebar">
<div class="inner">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php $term = $wp_query->queried_object; echo '<h2>'.$term->name.'</h2>'; ?>
<?php $term = new WP_Query('post_type=listing', 'taxonomy=new-developments', 'field=slug', 'terms=doral'); ?>
<?php if ($term->have_posts()) : while ($term->have_posts()) : $term->the_post(); ?>
<?php include 'includes/variables.php' ?>
<div class="searchresult">
<?php
$arr_sliderimages = get_gallery_images();
//$firstimage = $arr_sliderimages[0];
//$arr_sliderimages = parse_url($firstimage);
$resized = aq_resize($arr_sliderimages[0], 250, 185, true);
?>
<div class="resultimage">
<?php include 'includes/bannerssmall.php'; ?>
<?php if ($mlslisting == "Yes" && $mlsnumber) { ?>
<a href="<?php bloginfo('url') ?>/idx/mls-<?php echo $mlsnumber ?>-"><img width="250" height="185" alt="Image for <?php the_title(); ?>" src="<?php echo $resized ?>" /></a>
<?php } else { ?>
<a href="<?php the_permalink(); ?>"><img width="250" height="185" alt="Image for <?php the_title(); ?>" src="<?php echo $resized ?>" /></a>
<?php } ?>
</div>
<div class="resultdetails">
<div class="primary-data">
<div class="address">
<?php if ($mlslisting == "Yes" && $mlsnumber) { ?>
<a href="<?php bloginfo('url') ?>/idx/mls-<?php echo $mlsnumber ?>-"><?php the_title() ?>, <?php echo $citystatezip ?></a>
<?php } else { ?>
<a href="<?php the_permalink() ?>"><?php the_title() ?>, <?php echo $citystatezip ?></a>
<?php } ?>
</div>
<div class="price">
<?php include 'includes/price.php'; ?>
</div>
</div>
<div class="secondary-data">
<?php if ($beds) { ?>
<div><?php echo $beds ?> <?php echo get_option('wp_bedrooms_text'); ?>, <?php echo $baths; ?> <?php echo get_option('wp_bathrooms_text'); ?></div>
<?php } ?>
<?php if ($homesize) { ?>
<div><?php echo get_option('wp_homesize_text') ?>: <?php echo $homesize ?></div>
<?php } ?>
<?php if ($lotsize) { ?>
<div><?php echo get_option('wp_lotsize_text') ?>: <?php echo $lotsize ?></div>
<?php } ?>
<?php if ($year) { ?>
<div><?php echo get_option('wp_yearbuilt_text') ?>: <?php echo $year ?></div>
<?php } ?>
</div>
<a class="button" href="<?php the_permalink(); ?>"><?php echo get_option('wp_read_more_text') ?></a>
</div><!-- end resultdetails -->
</div><!-- end searchresult -->
<?php endwhile; else: ?>
<p><strong>There are no items to display. Make sure you add 1 or more posts using the "Listings" category. Also, in Theme Options, make sure the slideshow is using the "Listings" category.</strong></p>
<?php endif;
wp_reset_query(); ?>
</div><!-- end inner -->
</div><!-- end content -->
</div><!-- end columnswrapper -->
<?php get_footer(); ?>
我一直在努力让自己变得太久,并且迫切需要一些帮助来完成这项工作。
在此先感谢您的帮助。
========================================== 编辑:根据评论尝试过这个,但它是还是行不通 -
<?php
/*
Template Name: Taxonomy New Developments
*/
?>
<?php get_header() ?>
<div id="columnswrapper" class="columns-1">
<?php get_sidebar(); ?>
<div id="content" class="norightsidebar">
<div class="inner">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php $term = $wp_query->queried_object; echo '<h2>'.$term->name.'</h2>'; ?>
<?php $term = new WP_Query('post_type=listing', 'taxonomy=new-developments', 'field=slug', 'terms=doral'); ?>
<?php if ($term->have_posts()) :
$args = array(
'post_type' => 'Listing',
'new-developments' => $term->slug
);
query_posts($args);
while ($term->have_posts()) : $term->the_post(); ?>
<?php include 'includes/variables.php' ?>
<div class="searchresult">
<?php
$arr_sliderimages = get_gallery_images();
//$firstimage = $arr_sliderimages[0];
//$arr_sliderimages = parse_url($firstimage);
$resized = aq_resize($arr_sliderimages[0], 250, 185, true);
?>
<div class="resultimage">
<?php include 'includes/bannerssmall.php'; ?>
<?php if ($mlslisting == "Yes" && $mlsnumber) { ?>
<a href="<?php bloginfo('url') ?>/idx/mls-<?php echo $mlsnumber ?>-"><img width="250" height="185" alt="Image for <?php the_title(); ?>" src="<?php echo $resized ?>" /></a>
<?php } else { ?>
<a href="<?php the_permalink(); ?>"><img width="250" height="185" alt="Image for <?php the_title(); ?>" src="<?php echo $resized ?>" /></a>
<?php } ?>
</div>
<div class="resultdetails">
<div class="primary-data">
<div class="address">
<?php if ($mlslisting == "Yes" && $mlsnumber) { ?>
<a href="<?php bloginfo('url') ?>/idx/mls-<?php echo $mlsnumber ?>-"><?php the_title() ?>, <?php echo $citystatezip ?></a>
<?php } else { ?>
<a href="<?php the_permalink() ?>"><?php the_title() ?>, <?php echo $citystatezip ?></a>
<?php } ?>
</div>
<div class="price">
<?php include 'includes/price.php'; ?>
</div>
</div>
<div class="secondary-data">
<?php if ($beds) { ?>
<div><?php echo $beds ?> <?php echo get_option('wp_bedrooms_text'); ?>, <?php echo $baths; ?> <?php echo get_option('wp_bathrooms_text'); ?></div>
<?php } ?>
<?php if ($homesize) { ?>
<div><?php echo get_option('wp_homesize_text') ?>: <?php echo $homesize ?></div>
<?php } ?>
<?php if ($lotsize) { ?>
<div><?php echo get_option('wp_lotsize_text') ?>: <?php echo $lotsize ?></div>
<?php } ?>
<?php if ($year) { ?>
<div><?php echo get_option('wp_yearbuilt_text') ?>: <?php echo $year ?></div>
<?php } ?>
</div>
<a class="button" href="<?php the_permalink(); ?>"><?php echo get_option('wp_read_more_text') ?></a>
</div><!-- end resultdetails -->
</div><!-- end searchresult -->
<?php endwhile; else: ?>
<p><strong>There are no items to display. Make sure you add 1 or more posts using the "Listings" category. Also, in Theme Options, make sure the slideshow is using the "Listings" category.</strong></p>
<?php endif;
wp_reset_query(); ?>
</div><!-- end inner -->
</div><!-- end content -->
</div><!-- end columnswrapper -->
<?php get_footer(); ?>