Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. <div class="col-lg-9 col-12">
  2. <div class="row">
  3. <?php
  4. // global $wp_query, $paged;
  5. $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  6. $args = array(
  7. 'post_type' => 'noticias' ,
  8. 'orderby' => 'date' ,
  9. 'posts_per_page' => '2',
  10. 'order' => 'DESC' ,
  11. 'paged' => $paged,
  12. );
  13. $wp_query = new WP_Query($args);
  14.  
  15. if ($wp_query->have_posts()) :
  16. while ($wp_query->have_posts()) : $wp_query->the_post();
  17. $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'full');
  18. ?>
  19. <div class="col-md-6 col-12">
  20.  
  21. <div class="product__thumb">
  22. <div class="img-historias"><img src="<?php echo esc_url($featured_img_url); ?>" alt="product image"></div>
  23.  
  24. </div>
  25. <a href="<?php echo get_the_permalink(); ?>"><h4 class="title_historias"><?php the_title(); ?></h4></a>
  26. <hr>
  27. <div class="content_historias text-justify"><?php the_excerpt(); ?></div>
  28.  
  29. </div>
  30. <?php
  31.  
  32. endwhile;
  33. $total_pages = $wp_query->max_num_pages;
  34. if ($total_pages > 1){
  35.  
  36. $current_page = max(1, get_query_var('paged'));
  37. ?>
  38. <div class="clearfix hide_home">&nbsp;</div>
  39. <nav aria-label="Page navigation example">
  40. <?php
  41.  
  42. $links = paginate_links( array(
  43. 'base' => get_pagenum_link(1) . '%_%',
  44. 'format' => 'page/%#%',
  45. 'current' => $current_page,
  46. 'total' => $total_pages,
  47. 'prev_next' => false,
  48. 'type' => 'array'
  49. ) );
  50.  
  51. if ( $links ) :
  52.  
  53. echo '<ul class="pagination justify-content-end">';
  54.  
  55. // get_previous_posts_link will return a string or void if no link is set.
  56. if ( $prev_posts_link = get_previous_posts_link( __( 'ยซ' ) ) ) :
  57. echo '<li class="page-item rounded-0 paginate-prev">';
  58. echo $prev_posts_link;
  59. echo '</li>';
  60. endif;
  61.  
  62. echo '<li class="page-item rounded-0">';
  63. echo join( '</li><li class="page-item">', $links );
  64. echo '</li>';
  65.  
  66. // get_next_posts_link will return a string or void if no link is set.
  67. if ( $next_posts_link = get_next_posts_link( __( 'ยป' ) ) ) :
  68. echo '<li class="page-item rounded-0 paginate-next">';
  69. echo $next_posts_link;
  70. echo '</li>';
  71. endif;
  72. echo '</ul>';
  73. endif;
  74. }
  75. ?>
  76. </nav>
  77. <?php
  78.  
  79.  
  80. endif;
  81. wp_reset_postdata();
  82.  
  83. ?>
  84.  
  85. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement