Advertisement
iftekharul

Show Custom Post using Order by

Mar 11th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php
  2. $post_type = 'custom_post_type';
  3. $post_tax = 'custom_post_taxonomy';
  4. $posts_per_pag = 4;
  5. $tax_terms = get_terms($post_tax, array('orderby' => 'id', 'order' => 'DESC'));
  6. if ($tax_terms) {
  7.     foreach ($tax_terms as $tax_term) {
  8.         $args = array('post_type' => $post_type, "$post_tax" => $tax_term->slug, 'posts_per_page' => $posts_per_page, 'paged' => $paged);
  9.         $t4b_query = new WP_Query($args);
  10.         if ($t4b_query->have_posts()) :
  11.             while ($t4b_query->have_posts()) : $t4b_query->the_post(); ?>
  12.                 <div><!--SHOW CUSTOM POST ITEMS --></div><?php
  13.             endwhile;
  14.             getpagenavi();
  15.             wp_reset_query();
  16.         else : ?>
  17.             <h2>Not Found</h2><?php
  18.         endif;
  19.     }
  20. }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement