Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="row">
- <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 list-blog">
- <?php
- $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
- $args = array(
- 'post_type' => 'post',
- 'posts_per_page' => 4,
- 'paged' => $paged,
- );
- $query = new WP_Query( $args );
- $index = 0;
- if( $query->have_posts() ) {
- ?>
- <div class="row infinte-post">
- <?php
- while( $query->have_posts() ) {
- $query->the_post();
- $class = 'col-xl-3 col-lg-6 col-md-6 col-sm-12 col-12 post-item-inf';
- if( $index == 0 ) {
- $class = 'col-xl-3 col-lg-6 col-md-6 col-sm-12 col-12 post-item-inf';
- }
- $low_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' );
- $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
- $alt = get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true);
- $title = get_the_title();
- $category = get_the_category()[0]->name;
- $thumbnails = $thumbnail[0];
- $allcat = get_the_category();
- $allcatarray = [];
- foreach ($allcat as $categori) {
- $allcatarray[] = $categori->name;
- }
- ?>
- <div class="<?php echo $class; ?> <?php echo $index; ?>">
- <a href="<?php echo get_permalink(); ?>">
- <div class="thumb lazy-wrapper">
- <img src="<?php echo $thumbnails; ?>" data-src="<?php echo $thumbnails; ?>" alt="<?php echo $alt; ?>" class="lazyload">
- </div>
- <div class="content">
- <div class="meta">
- <label class="category"><?php echo implode(", ", $allcatarray); ?></label>
- <h2><?php echo $title; ?></h2>
- </div>
- <p class="permalink">Read</p>
- </div>
- </a>
- </div>
- <?php
- $index++;
- }
- ?>
- </div><!-- end-div -->
- <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
- <!-- status elements -->
- <div class="scroller-status">
- <div class="infinite-scroll-request loader-ellips">
- <div class="LoaderBalls">
- <div class="LoaderBalls__item"></div>
- <div class="LoaderBalls__item"></div>
- <div class="LoaderBalls__item"></div>
- </div>
- </div>
- <p class="infinite-scroll-last"></p>
- <p class="infinite-scroll-error">No more pages to load</p>
- </div>
- <div class="row">
- <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 arc-nav">
- <?php
- if (function_exists( 'custom_pagination' )) :
- custom_pagination( $query->max_num_pages,"",$paged );
- endif;
- ?>
- </div>
- </div>
- </div>
- <?php
- wp_reset_postdata();
- }
- ?>
- </div>
- <?php
- function custom_pagination( $numpages = '', $pagerange = '', $paged='' ) {
- if (empty($pagerange)) {
- $pagerange = 2;
- }
- /**
- * This first part of our function is a fallback
- * for custom pagination inside a regular loop that
- * uses the global $paged and global $wp_query variables.
- *
- * It's good because we can now override default pagination
- * in our theme, and use this function in default queries
- * and custom queries.
- */
- global $paged;
- if (empty($paged)) {
- $paged = 1;
- }
- if ($numpages == '') {
- global $wp_query;
- $numpages = $wp_query->max_num_pages;
- if(!$numpages) {
- $numpages = 1;
- }
- }
- /**
- * We construct the pagination arguments to enter into our paginate_links
- * function.
- */
- $pagination_args = array(
- 'base' => get_pagenum_link(1) . '%_%',
- 'format' => 'page/%#%',
- 'total' => $numpages,
- 'show_all' => False,
- 'end_size' => 1,
- 'mid_size' => $pagerange,
- 'prev_next' => True,
- 'prev_text' => __('Previos page'),
- 'next_text' => __('Next page'),
- 'type' => 'plain',
- 'add_args' => false,
- 'add_fragment' => ''
- );
- $paginate_links = paginate_links($pagination_args);
- if ($paginate_links) {
- echo "<nav class='custom-pagination'>";
- echo $paginate_links;
- echo "</nav>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement