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.


[code]


<?php
$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="http://www.metalpaths.com/wp-content/themes/Avenue/timthumb.php?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>
</li>
<?php endwhile; ?>
</ul></div>


<?php kriesi_pagination($my_query->max_num_pages); ?>
[/code]

Answers (2)

2012-10-13

Arnav Joy answers:

try this

<?php
$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();
?>

2012-10-13

Christianto answers:

Hi,

-Please check the category name if it correct,

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