Guest User

Untitled

a guest
Oct 18th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. <?php
  2.  
  3. if ( get_query_var( ‘paged’ ) )
  4. $paged = get_query_var(‘paged’);
  5. else if ( get_query_var( ‘page’ ) )
  6. $paged = get_query_var( ‘page’ );
  7. else
  8. $paged = 1;
  9.  
  10. $per_page = 1;
  11. $number_of_series = count( get_terms( array( 'taxonomy' => 'attornies_cat' ) ) );
  12. $offset = ( ( $paged - 1 ) * $per_page );
  13.  
  14. $terms = get_terms( array(
  15. 'taxonomy' => 'attornies_cat',
  16. 'orderby' => 'term_id',
  17. 'order' => 'ASC',
  18. 'offset' => $offset,
  19. 'number' => $per_page,
  20. ) );
  21.  
  22. if ( $terms && !is_wp_error( $terms ) ) :
  23. ?>
  24.  
  25. <?php foreach ( $terms as $term ) : ?>
  26.  
  27. <!-- ATTORNEY DISTRICT AREA -->
  28. <div class="attorney-district-area">
  29.  
  30. <h2><?php echo $term->name; ?></h2>
  31.  
  32. <div class="row">
  33.  
  34.  
  35. <?php
  36.  
  37. $attornies_post_type = new WP_Query( array(
  38. 'post_type' => 'attornies',
  39. 'orderby' => 'menu_order',
  40. 'order' => 'ASC',
  41. 'tax_query' => array(
  42. array(
  43. 'taxonomy' => 'attornies_cat',
  44. 'field' => 'name',
  45. 'terms' => $term->name,
  46. )
  47. )
  48. ) );
  49.  
  50. if( $attornies_post_type->have_posts() ) :
  51.  
  52. while( $attornies_post_type->have_posts() ) : $attornies_post_type->the_post();
  53.  
  54. $attorney_sec_meta = get_post_meta($post->ID, '_custom_meta_options', true);
  55. ?>
  56.  
  57. <!-- SINGLE ATTORNEY -->
  58. <div class="col-md-4 col-sm-6">
  59. <div class="single-attorney">
  60. <div class="single-attorney-img">
  61.  
  62. <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'attorney_thumb' ); } ?>
  63.  
  64. <div class="single-attorney-link">
  65. <a href="#"><i class="fa fa-link" aria-hidden="true"></i></a>
  66. </div>
  67. </div>
  68. <div class="single-attorney-con">
  69.  
  70. <h3><?php the_title(); ?></h3>
  71.  
  72. <?php if( $attorney_sec_meta[ 'attorney_phone_no' ] ) : ?>
  73. <span><?php echo $attorney_sec_meta[ 'attorney_phone_no' ] ?></span>
  74. <?php endif; ?>
  75.  
  76. </div>
  77. </div>
  78. </div><!-- // END SINGLE ATTORNEY -->
  79.  
  80. <?php
  81.  
  82. endwhile;
  83.  
  84. wp_reset_postdata();
  85.  
  86. endif;
  87.  
  88. ?>
  89.  
  90. </div>
  91. </div><!-- // END ATTORNEY DISTRICT AREA -->
  92.  
  93. <?php
  94.  
  95. endforeach;
  96.  
  97. // Attorney Pagination
  98. echo '<div>';
  99.  
  100. $big = 999999;
  101.  
  102. echo paginate_links( array(
  103. 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  104. 'format' => '?paged=%#%',
  105. 'current' => $paged,
  106. 'total' => ceil( $number_of_series / $per_page ),
  107. ) );
  108.  
  109. echo '</div>';
  110.  
  111. endif; ?>
Add Comment
Please, Sign In to add comment