php - Get categories and then posts for custom post type -


thanks reading post..

i using wplms theme , custom post type registered 'course'

i getting post's code:

$args = array( 'orderby'          => 'date', 'order'            => 'desc', 'post_type'        => 'course', 'post_status'      => 'publish', 'suppress_filters' => true  

i want categories , posts each category.

example: category name : education , posts education, want categories name , respective post, or category names , posts posts must have category name well.

i hope work's.

thanks in advance

this code list posts according categories:

 $categories = get_terms( 'category' );         foreach ($categories $key => $value) {             $args = array(         'posts_per_page'   => -1,         'offset'           => 0,         'category'         => $value->term_id, // tells category id         'post_type'        => 'course',         'post_status'      => 'publish',         'suppress_filters' => true          );         $posts_array = get_posts( $args );          echo "<pre>{$value->name}";          print_r($posts_array);         echo "</pre>"; } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -