• Resolved sideswipev2

    (@sideswipev2)


    I’ve recently put together a website for a local golf club. The front page has 2 sections for “featured posts” that show 3 posts each. The first shows latest posts to category A and only category A. The second set of featured posts shows ANY latest posts. I’ve added the ‘do not duplicate’ lines so there isn’t any overlap.

    I’m not phenomenal with php, but I hashed together the code from using the WordPress resources but for some reason the sections randomly have changed from 3 posts to 2 posts. Can anyone point me towards where I’m going wrong?

    This is the code for the first set of featured posts that only show category A.

    <?php $the_query = new WP_Query('category_name=frontpage&showposts=3'); ?>
        <?php while ($the_query -> have_posts()) : $the_query -> the_post();
        $do_not_duplicate[] = $post->ID;?>
    
        <li><a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_post_thumbnail('homepage-post-thumbnail', array('class' => 'box-image', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?></a>
        <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
        <div class="content-ver-sep"></div>
        <p><?php the_excerpt(__('(more…)')); ?></p></li>
        <?php endwhile;?>

    Here is the code for the second featured post section that shows any new posts.

    <?php if (have_posts('showposts=3')) : while (have_posts()) : the_post();
     if (in_array($post->ID, $do_not_duplicate)) continue;
     ?>
    
        <li><a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_post_thumbnail('homepage-post-thumbnail', array('class' => 'box-image', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?></a>
        <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
        <div class="content-ver-sep"></div>
        <p><?php the_excerpt(__('(more…)')); ?></p></li>
        <?php endwhile; endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘"Featured posts" changes the number shown’ is closed to new replies.