Support » Fixing WordPress » List the posts that are in my category

  • Hello everyone,

    I having a problem with creating a list of posts of a specific category, but not only just a list- I want to make it possible for people to be able to click “Next” and display the a new page of results. Here is my site: – if you click on one of the genre pages you will see it displays 10 results and has the feature of clicking “next page”, but when you do it it will display the same 10 posts… I know that the code I done at least collects all of the posts because on each genre page it has a different amount of search pages to click on (for example ‘adventure’ as 4 pages and ‘action’ has 5). So my main problem is really continuing the list through to the next page. Please could someone help me. Sadly my knowledge of php isnt that strong so if you could explain it in easy terms i would be greatful

    div id="<?php echo $content_id?>" class="div-content clearfix">
    <? query_posts('cat=12'); ?>
        	<?php if ( have_posts() ) : ?>
    		<?php if($swift_design_options['blog_or_mag_archives']=='list')
    		echo '<ul class="post-listing">'?>
    		<?php /* Start the Loop */ ?>
    		<?php while ( have_posts() ) : the_post(); ?>
    			<?php get_template_part( $layout, get_post_format() ); ?>
    		<?php endwhile; ?>
    		<?php if($swift_design_options['blog_or_mag_archives']=='list') echo '</ul>'?>

    That is the code im currently using, again it is very basic as im not that familiar with the language


Viewing 3 replies - 1 through 3 (of 3 total)
  • You must include the ‘paged’ option in your query_posts() in order for WP to know which page to display.

    Try changing this:

    <? query_posts('cat=12'); ?>

    to this:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=12&paged=$paged"); ?>

    Note the double quotes around the query_posts() arguments.

    BTW, you should always use <?php instead of just <?.

    Thank you, thank you, thank you so so much!!!

    This worked perfectly! I was reading on the internet that I need to use the “$paged” but no one ever explained it

    Also about the <? / <?php I usually do use it, that was properly just a typo… thanks for noticing haha

    Thank you so much once again! youre a life saver and true php master 😀

    If your problem has been solved, please use the dropdown on the right to mark this topic ‘Resolved’ so that anyone else with this question can see that there is a solution.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘List the posts that are in my category’ is closed to new replies.