custom tax and post types
-
I created two custom post types ( smartphones and tablets ) and a custom taxonomy ( brand ) assigned to both of them.
Now, i would like to display the tax terms, created in both of cpt, as links and then when one clicks on a link, the posts of the cpt ( and only that cpt ) display.
Example of code:$terms = get_terms( 'marque' ); //ce qui permet d'avoir le term_name et term_id $query = new WP_Query( array('post_type' => 'smartphones', 'tax_query' => array( array( 'taxonomy' => 'marque', 'filed' => $term->term_id ), ), ), ); if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); foreach($terms as $term){ //$term_link = get_term_link( $term ); echo '<li><a href="'; the_permalink(); echo '">'; the_title(); echo '</a></li>'; } endwhile; endif; wp_reset_postdata();
would you please help????
thank you.
- The topic ‘custom tax and post types’ is closed to new replies.