Dispay random post types on custom WordPress page with pagin... open

Dispay random post types on custom WordPress page with pagination. Code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
Tested: PHP 5.6 +
		$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
		$args  = array(
			'posts_per_page' => 12,
			'meta_key' => 'songs_views',
			'orderby' => 'meta_value_num',
			'order' => 'DESC',
			'paged' => $paged
		);
		$query = new WP_Query( $args );
		if ( $query->have_posts() ) :
			while ( $query->have_posts() ) :
				$query->the_post();
				get_template_part( 'content-standard' );
			endwhile;
			echo '<div class="pagination">';
			echo paginate_links( array(
				'total' => $query->max_num_pages,
				'current' => max( 1, get_query_var( 'paged' ) ),
				'prev_next' => true,
                'prev_text'    => __('« Попередня сторінка'),
                'next_text'    => __('Наступна сторінка »'), 
                'show_all'     => False,           
				'type' => 'plain',
                'aria-current' => 'page',
			) );
			echo '</div>';
			?>

			<?php
		else :
			_e( 'Posts Not Found', 'typecore' );
		endif;
		wp_reset_postdata();
	
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation