WordPress.org

Ready to get started?Download WordPress

Forums

Urgent Help Needed : Caught spinning in loops (3 posts)

  1. quemultimedia
    Member
    Posted 4 years ago #

    Greetings Guys,

    I'm trying to use WordPress creatively, and, thus, I'm trying to implement a custom home-page layout. Here is what I want to do:

    - At the top of the page, just after the menu/ navigation, I would like to have a slideshow {using JavaScript} of 4 posts from the same category{i.e. Large Image/ Thumbnail, Title, Excerpt}.

    - Thereafter, a 3-column listing of 3 articles from the same category {i.e. Title, Thumbnail, Excerpt}. To Illustrate:

    | SlideShow Here[4 Posts from same category] |

    |Post 1 || Post 2 || Post 3 | [3 Posts Randomized from another category]

    Any guidance is very much welcomed and appreciated. I have already prepared my intended XHTML/ CSS layout, and will greatly appreciate help with the loops. Thanks.

  2. quemultimedia
    Member
    Posted 4 years ago #

    Greetings Guys,

    Have been toying arround with different code snippets {Have been scouring through the WordPress Codex trying to see whether I can get a solution on my own}, the following seems to work, however, instead of showing only 3 articles {randomized of course}, it duplicates and shows 6 instead.

    Could I be on the right track, or am I getting more and more lost?

    Any help is greatly appreciated.

    Rgds
    Q

    <!-- begin content container -->
    	<div class="content pngfix">
    
    		<!-- clearing div -->
    		<div class="clear"></div>
    
    			  <h1><a href="/?page_id=xxx">Category Title Here</a>
    			  <!-- subtitle-->
    			  <span>Some Description Here for the Category</span>
    			  </h1>
    
    <?php query_posts('posts_per_page=3&cat=11'); ?>
    <?php $posts = get_posts('numberposts=3&category=11&orderby=rand'); foreach ($posts as $post) : start_wp(); ?>
    
    			<?php
    
                $col = 0;
                $cols_per_row = 3;
                while (have_posts()) : the_post();
                  if($col == 0) echo '';
                  ?>
    
                        <!-- Column -->
                        <div class="grid_8 column'<?php echo $col; ?>">
                            <!-- begin spacing div -->
                            <div class="pngfix">
                                <h2><?php the_title(); ?></h2>
    
                                <p>
                                    <a href="<?php the_permalink(); ?>"><img class="frame" src="<?php $thumb = get_post_custom_values('project-image'); echo $thumb[0]; ?>" alt="<?php the_title(); ?>" /></a>
    
                                <?php the_content_rss('', TRUE, '', 28); ?>
    
                                    <a href="<?php the_permalink(); ?>" class="more">
                                        <img src="<?php bloginfo('url'); ?>/wp-content/themes/ANAW-Theme/images/btn-read-more.png" alt="Read more on this entry..." />
                                    </a>
                                </p>      
    
                            </div><!-- end begin spacing div -->
                        </div><!-- End Column -->
    
    			  <?php
                  if($col++ >= $cols_per_row){
                    $col = 0;
                    echo '';
                  }
                endwhile;
                ?>
    
    <?php endforeach; ?>
  3. quemultimedia
    Member
    Posted 4 years ago #

    Greetings Guys,

    Still not giving up on my attempts, just noted some more problems with the above code:

    - Not only are the posts not limited to 3 [i.e. if one has say, 10 articles in the category, all 10 show up], but also, the <div class="grid_8 column"> containers are now not of equal length [i.e. if one 'container' has more content/ longer thumbnail image, the design 'breaks'.

    Really eager to learn something new....

Topic Closed

This topic has been closed to new replies.

About this Topic