Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

WordPress Custom Loop Pagination Problem WordPress

Here is my Code, and the pagination is NOT Working.


$my_query = new WP_Query('category_name=reviews&showposts=30&paged=$paged'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

<li><img src="<?php echo the_field('coverimage'); ?>&h=100&w=100"/>
<a href="<?php the_permalink(); ?>"><strong><?php echo get_post_meta($post->ID, "band_name", $single = true); ?></strong> <br /><?php echo get_post_meta($post->ID, "album_name", $single = true); ?></a>
<?php endwhile; ?>

<?php kriesi_pagination($my_query->max_num_pages); ?>

Answers (2)


Arnav Joy answers:

try this

$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$my_query = new WP_Query('category_name=reviews&showposts=30&paged=$paged'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post();


Christianto answers:


-Please check the category name if it correct,

-For the custom query, use double quote if you need to pass $paged value..
$my_query = new WP_Query('category_name=reviews&showposts=30&paged=$paged'); ?>
$my_query = new WP_Query("category_name=reviews&showposts=30&paged=$paged"); ?>

or concatenate it
$my_query = new WP_Query('category_name=reviews&showposts=30&paged='.$paged); ?>

-you can use posts_per_page instead of showposts..
$my_query = new WP_Query("category_name=reviews&posts_per_page=30&paged=$paged"); ?>

-check if $my_query->max_num_pages return a value that > 1, and check if your category has more than 30 posts