• Resolved getgood

    (@getgood)


    Hi, I have a problem with listing all posts in a category in a category page. I’ve been using this code to list them…

    <?php echo '';
    
    foreach( $posts as $post ) {
    	echo '><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a><br />';}?>

    But for some reason it doesn’t list all of the posts, it cuts off after the 10th post… Anyone know why??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Probably because you have set ‘Blog pages show at most’ to 10 in Admin->Settings->Reading.

    Try using this:

    global $wp_query;
    query_posts(
       array_merge(
          array('posts_per_page' => -1),
             $wp_query->query
          )
    );
    foreach( $posts as $post ) {
       echo '><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a><br />';}?>
    Thread Starter getgood

    (@getgood)

    Thanks so much vtxyzzy, can’t describe how much I appreciate your help. I was so much into the code, I didn’t look outside the box (literally) and check the wordpress settings themselves!

    Any reason you’re not using a regular loop for that page?..

    IIRC , $post->stuff is not sanitized …

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘I have PHP code working but still have problems’ is closed to new replies.