@juggledad
get_the_categories() will not work in taxonomy context, because with this code you must query an object, not an array
@doublee_design
get_terms is about the same as wp_get_post_terms, no?
@perotin
Hi,
Thanks for your share, in return I put here what I did for a custom taxonomy page (this was coded to display only posts that match a taxonomy (brand) and a date range, like for limited-time deals, vouchers so on. Cross referenced to 3 taxonomies (brand, product & merchant).
Code is far from perfect but was working rather well in terms of performance. Some terms are in french but I guess you catch it (yes = oui, no = non).
For date range, I was using custom fields, hence php conversion to format strings to date and the opposite.
It might help others if they want to build a full custom taxonomy page.
<?php
/*
Used with filename, taxonomy-brand.php and accessed from:
http://www.yoursite.com/brands/thebrand/
*/
?>
<?php get_header(); ?>
<div class="site-content">
<h1 class="titre-accueil">Last deals for <?php echo $wp_query->queried_object->name; ?></h1>
<ul class="liste">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<li>
<?php print apply_filters( 'taxonomy-images-queried-term-image', '' );?>
<div class="colonne-droite">
<h2 class="titre-vente"><?php the_title(); ?><span> sur <?php echo get_the_term_list( $post->ID, 'merchant' ) ?></span></h2>
<?php the_excerpt(); ?>
<?php
$deb_date = get_post_meta( get_the_ID(), 'Begin_date', true );
$debut_date = strtotime($deb_date);
$exp_date = get_post_meta( get_the_ID(), 'End_date', true );
$expiration_date = strtotime($exp_date);
$today_date = date("d-m-Y");
$today_date2 = strtotime($today_date);
echo "<p>from $begin_date to $exp_date</p>";
if( $today_date2 > $expiration_date )
{
$expire = "oui";
} else {
$expire = "non";
}
if( $expire == "oui" )
{
echo "<p class='bouton-wrapper'><span class='vente-privee-bouton termine'>Deal ended</span></p>";
} else {
echo "<p class='bouton-wrapper'><a class='vente-privee-bouton' href=" . get_post_meta( get_the_ID(), 'Lien', true ) . ">Check deal</a></p>";
}
?>
<?php echo get_the_term_list( $post->ID, 'product', '<p>Universe : ', ', ', '</p>' ) ?>
</div>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
<?php if ( is_active_sidebar( 'taxo-brand-sidebar-1' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php
$terms = get_the_terms( $post->ID , 'brand' );
if($terms) {
foreach( $terms as $term ) {
echo "<p>";
echo $term->description.'</p><br />';
}
}
?>
<?php dynamic_sidebar( 'taxo-brand-sidebar-1' ); ?>
</div><!-- #secondary -->
<?php endif; ?>
<?php get_footer(); ?>