• Hi,
    I´m intressted in query categories from a custom posttype
    into my sidebar as a navigation. Is there any easy way?

Viewing 1 replies (of 1 total)
  • Hello, that should help. “types” are category(ie taxonomy) within your custom postype. “references” is the custom post type in my code

    <?php
            $terms = get_terms("types");
            $count = count($terms);
     	if ( $count > 0 ){
     	  foreach ( $terms as $term ) {
    	  echo "<h2>" . $term->name . "</h2>";
    	  $args = array(
                   'numberposts' => 1,
                   'orderby' => 'post_date',
        	       'order'           => 'DESC',
       	       'post_type' => 'references',
       	       'types' => $term->slug,
       	       'post_status' => 'publish'
    	   );
               $sommaire_cat = get_posts ( $args );
    	   foreach( $sommaire_cat as $post ) : ?>
               <a href="<?php the_permalink(); ?>"><?php the_title();?></a>
    	   <?php endforeach;
    		 }
    
     	 }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Query categories from a custom posttype?’ is closed to new replies.