Forums

[resolved] Previous / Next on Page Special Code (12 posts)

  1. noelgreen
    Member
    Posted 1 year ago #

    The previous and next buttons aren't working on my pages.

    First of all, I'm using 2 plug-ins.
    The 1st is the "post image" plug-in, the 2nd is the "WP-PageNavi" plug-in.

    I will say too that this doesn't work if I remove the "WP-PageNavi" plug-in. I can't afford to remove the "post image" plug-in as that's what's making the page display as I want it to.

    So, any ideas?

  2. noelgreen
    Member
    Posted 1 year ago #

    Here's my code.

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $posts = query_posts('category_name=portfolio&showposts=6&paged=$page');
    foreach ($posts as $post) : start_wp();
    ?>
    
    <a href="<?php the_permalink() ?>" rel="bookmark" title="view details..."><?php post_image('default_image', 'use_thumb=1'); ?></a>
    
    <?php endforeach; ?>
    
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
  3. moshu
    Member
    Posted 1 year ago #

    The previous and next buttons aren't working on my pages.

    Do you mean Pages? It is not supposed to work on them.

    Is it about the blog linked to your profile?

  4. noelgreen
    Member
    Posted 1 year ago #

    Yes, I mean pages... and no, it's this site.

  5. Otto42
    Moderator
    Posted 1 year ago #

    Hmm... Okay, I sorta see what you're doing there.. I don't much like your loop though. It's weird.

    Try something more like this:

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('category_name=portfolio&showposts=6&paged=$page');
    while (have_posts()) : the_post();
    ?>
    ... blah ...
    <?php endwhile; ?>
  6. noelgreen
    Member
    Posted 1 year ago #

    Ahhh... I see that blue-underwater icon and KNOW there is hope! :)

    Tried that, and now it doesn't show the posts either.

  7. Otto42
    Moderator
    Posted 1 year ago #

    Actually, it's showing the post links fine, just not the images. Look at the source:

    ...
    <a href="http://www.parkeastinc.com/2.0/portfolio/couponfridgecom.php" rel="bookmark" title="view details..."></a>
    <a href="http://www.parkeastinc.com/2.0/portfolio/east-grand-church-of-christ.php" rel="bookmark" title="view details..."></a>
    ...

    So that post image thing is having some sort of issue with the new stuff. What plugin is that?

  8. Otto42
    Moderator
    Posted 1 year ago #

    Also, the paging seems to work fine on your normal category pages...
    http://www.parkeastinc.com/2.0/category/portfolio/page/2

  9. noelgreen
    Member
    Posted 1 year ago #

    It's the "post image" plug-in. It allows me to show the 1st image uploaded in a post, without showing the actual post content.

  10. Otto42
    Moderator
    Posted 1 year ago #

    Okay, I looked at the post image source. Seems a bit complex to me, might not work with 2.5 properly in all cases.

    You could try something like this instead:

    $attachments = get_children(array(
    'post_parent'=>$post->ID,
    'post_type'=>'attachment',
    'post_mime_type'=>'image',
    'orderby'=>'menu_order ASC, ID ASC',
    ));
    foreach ( $attachments as $att_id => $attachment ) {
     echo wp_get_attachment_image($att_id, 'medium');
     break;
    }

    That's just off-the-cuff code, might not work.

  11. noelgreen
    Member
    Posted 1 year ago #

    Haha... well, that got the image to display... but the pagination doesn't work again. (and the styling is screwy... but I could fix that) I put that code in place of the

    post_image('default_image', 'use_thumb=1');

    Correct?

    Maybe there's another way to display just the image from that post and not the post's content?

  12. noelgreen
    Member
    Posted 1 year ago #

    Got it... this works:

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=1&showposts=6&orderby=title&order=ASC&paged=$page");
    ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <a href="<?php the_permalink() ?>" rel="bookmark" title="view details...">
    <?php
    $attachments = get_children("post_parent={$post->ID}&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC");
    foreach ( $attachments as $att_id => $attachment ) {
     echo wp_get_attachment_image($att_id, 'medium');
     break;
    }
    ?>
    </a>
    
    <?php endwhile; ?>
    <?php endif; ?>

    Now I need to fix the styling.
    Thanks again Otto42!!

Topic Closed

This topic has been closed to new replies.

About this Topic