• Resolved noelgreen

    (@noelgreen)


    I’m using the Post Image plug-in and have this code on my sidebar to show all the image thumbnails of recent posts in a certain category:

    <?php $posts = get_posts('category=6&showposts=40');
    foreach ($posts as $post) : start_wp(); ?>
    
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Buy this..."><?php post_image('default_image', 'use_thumb=1'); ?></a>
    
    <?php endforeach; ?>

    It’s working fine, but its only showing the last 5 posts. Even if I change it so it’s just the post content (the_content) instead of the plug-in info, last five posts. Even if I delete the entire content of the main page, still only five.

    I’ve looked through my settings and every plug-in setting I know of I’ve even deactivated all my plug-ins. I’ve opened every file in my template and searched for anywhere that has “showposts” and changed and removed it and nothing.

    Why would this be showing only 5 posts??
    Any idea?

Viewing 8 replies - 1 through 8 (of 8 total)
  • i feel bad, you always seem to have questions no one can answer. i cant really help. the only thing i can think of is your “Show at most:” setting in your reading options. but i really doubt that would over ride your settings.

    p.s. i failed your muppet test cause boober wasnt on it ??

    Thread Starter noelgreen

    (@noelgreen)

    Hahaha… that’s very nice, thanks! ??

    I’m glad people are at least LOOKING at my posts. And I think you’re the first person I know who’s failed the Muppet Test! (I should add Boober.)

    Hopefully someone will be able to help on this one at least.

    Ok here’s a dumb question – but what DO you have as the number in Settings>Reading Blog pages show at most XX posts?

    Try this. On a local install I got it to spit out the same 15 images with excerpts while the main page is set to display only 5 posts. You’ll have to play around with it to get the result you want but it should get you started.

    <?php query_posts('category_name=test&showposts=15'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Buy this..."><?php post_image('/your/image/path/pic.gif', true); ?></a>
    <?php the_excerpt(); ?>
    <?php endwhile; ?><?php endif; ?>
    Thread Starter noelgreen

    (@noelgreen)

    TrishaM – never a dumb question, or at least sometimes the dumb questions are the ones I’ve overlooked… however, not in this case. It is set to 10, and I had tried setting it to 99. But thanks!

    LenK – That did it! ??
    Not sure what is different except you’re using “category_name” instead of “cat” and you have the “endwhile” and “endif” instead of the “endforeach”… but I don’t care why it’s working… it’s just working!

    Thanks!

    Thread Starter noelgreen

    (@noelgreen)

    Actually to get them to appear on ALL the pages (not just the homepage) I had to use this code:

    <?php $posts = query_posts('category_name=sidebar&showposts=-1');
    foreach ($posts as $post) : start_wp(); ?>
    
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Buy this..."><?php post_image('default_image', 'use_thumb=1'); ?></a>
    <?php endforeach; ?>

    It was the “query_posts” instead of “get_posts” that did it though.

    Thanks again everyone!
    And see boober… I get my questions answered now and then. ??

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Your basic problem is that you didn’t make a proper Loop correctly. Even your later example is incorrect and can cause other issues. I mean, it works, but only as a sort of side effect.

    Here’s a corrected example:

    <?php query_posts('category_name=sidebar&showposts=-1');
    while(have_posts()): the_post(); ?>
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Buy this..."><?php post_image('default_image', 'use_thumb=1'); ?></a>
    <?php endwhile; ?>

    However, this will mess with the main Loop and so it’s not a good thing to put in a sidebar. A better example would be this:

    <?php $my_query = new WP_Query('category_name=sidebar&showposts=-1');
    while($my_query->have_posts()): $my_query->the_post(); ?>
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Buy this..."><?php post_image('default_image', 'use_thumb=1'); ?></a>
    <?php endwhile; ?>

    This second one uses a separate query to avoid contaminating the main one.

    woohoo noelgreen! im glad the real experts were able to fix it!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Only showing 5 posts’ is closed to new replies.