• Resolved Ann-Sophie

    (@ann-sophie)


    I would like to have 3 “services boxes” on the home page, but they can be whatever a client wants. The 3 boxes are dynamic, so a client can create a new post and choose the category “frontpage item” (category id = 5). Link

    This is my code:

    <div id="services">
    
    	<?php
    		global $post;
    		$args = array( 'numberposts' => 3, 'offset'=> 1, 'category' => 5 );
    		$myposts = get_posts( $args );
    		foreach( $myposts as $post ) :	setup_postdata($post); ?>
    
    			<div class="services-box">
    
    				<h4><?php the_title(); ?></h4>
    
                    		<?php the_post_thumbnail(); ?>
    
                    		<?php the_content(); ?>
    
                		</div>
    
    		<?php endforeach; ?>
    
        </div><!--end services-->

    So ‘numberposts’ is 3, but only 2 posts show up. I checked the latest post and it has the right category assigned to it. I would like to set ‘offset’ to 3, but then none show up. Any help is appreciated.

Viewing 1 replies (of 1 total)
  • Thread Starter Ann-Sophie

    (@ann-sophie)

    I used this code instead:

    <div id="services">
    
           <?php query_posts('category_name=voorpagina-item&showposts=3'); ?>
    
                <?php while (have_posts()) : the_post(); ?>
    
                    <div class="services-box">
    
                        <h4><?php the_title(); ?></h4>
    
                        <?php the_post_thumbnail(); ?>
    
                        <?php the_content(); ?>
    
                    </div>
    
                <?php endwhile;?>
    
      </div><!--end services-->
Viewing 1 replies (of 1 total)
  • The topic ‘Latest 3 posts from specific category’ is closed to new replies.