• I want to do the following: (Category is 8)

    Top Post
    P P
    P P
    P P

    One large top post that has the content displaying, then under that, the rest of the category’s posts in two columns. The problem is that

    <?php query_posts("orderby=rand&cat=8"); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div id="featured_work">
    <?php the_title(); ?>
    <?php the_content();?>
    </div>
    <?php while (have_posts()) : the_post(); ?>
    <div id="pw_columns">
    <?php  if ( has_post_thumbnail() ) { ?>
    <div class="init"><?php the_post_thumbnail('case-thumb'); ?></div>
    <?php } ?>
    <div class="short"><?php get_permalink();?></div>
    </div>

    Both 1) will repeat posts, which I don’t want and 2) repeats the top post.

    Any thoughts on how to make this work? thank you!

Viewing 1 replies (of 1 total)
  • Thread Starter Hitokage4

    (@hitokage4)

    I managed to figure it out though possibly not the most elegant solution!

    <?php query_posts("orderby=rand&cat=8&posts_per_page=1"); ?>
                                        <?php while (have_posts()) : the_post(); ?>
                                            <div id="featured_work">
                                            	<?php the_title(); ?>
                                                <?php the_content();?>
                                                <?php $already_displayed = get_the_ID(); ?>
                                            </div>
                                        <?php endwhile;?>
                                    <?php wp_reset_query(); //Reset Query ?>
                                    <?php query_posts("orderby=rand&cat=8"); ?>
                                        <?php while (have_posts()) : the_post(); ?>
                                        	<?php if(get_the_ID() == $already_displayed){ continue; } ?>
                                            <div id="pw_columns">
                                            	<?php the_title(); ?>
                                            	<?php  if ( has_post_thumbnail() ) {  // check if the post has a Post Thumbnail assigned to it. ?>
                                                    <div class="init"><a href="<?php get_permalink();?>"><?php the_post_thumbnail('case-thumb'); ?></a></div>
                                                <?php } ?>
                                            </div>
                                        <?php endwhile;?>
                                    <?php wp_reset_query(); //Reset Query ?>
Viewing 1 replies (of 1 total)

The topic ‘Random Posts – Not having luck’ is closed to new replies.