I’m a trying to set up an archive page with custom post types and custom taxonomy in WordPress.
I have created the custom post type: âpackageâ and the custom taxonomy: âsoftwareâ. My problem is that when I try to look at localhost:8888/software/aperture I get all the posts of the type package instead of just the ones with the custom taxonomy aperture selected. I am using the following code:
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
?>
<h1><?php echo $term->name;?> Presets</h1>
<div class="intro2">
<p>
<?php echo $term->description;?>
</p>
</div>
<?php query_posts('post_type=package'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- Product Start -->
<div class="product">
<div class="product_top"></div>
<div class="product_content">
<div class="product_image">
<a href="<?php the_permalink()?>">
<?php echo get_the_post_thumbnail( $id, $size, $attr ); ?>
</div>
<a href="<?php the_permalink()?>" class="title"><?php the_title()?></a>
<?php the_excerpt()?>
<div class="theprice">
<?php
$price = get_post_meta($post->ID, "price", true);
echo "$".$price;
?>
</div>
<a href="<?php the_permalink()?>" class="button calltoaction"><span>See The Presets</span></a>
<div class="clearboth"></div>
</div>
</div>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
How do I get this archive page to just show posts of the type package form the current selected item in the custom taxonomy?
By the way I used the plugins “More Types” and “More Taxonomies” to set it up.
Update: solved it:
Solved it myself by adding by setting Allow queries to true in the more taxonomies plugin and setting the variable to presets. Then I changed the query to:<?php query_posts(array( 'post_type'=>'package', 'presets' => $term->slug, 'posts_per_page' => -1 )); ?>
Modify
<?php query_posts('post_type=package'); ?>
with