pulling posts into a page template
< ? php global $post; $args = array( 'numberposts' => 6, ‘offset’=> 0, ‘category_name’ => ‘featured’, ‘orderby’ => ‘post_date’, ‘order’ => ‘DSC’); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ? > < div class="archive-thumb">< a href="< ? php the_permalink(); ? >” rel=”bookmark”> < ? php if ( has_post_thumbnail() ) { the_post_thumbnail('medium'); } else { ? > < img src="/images/default_thumbnail.jpg” alt=”” /> < ? php } ? > < / a>< /div> < div class="archive-excerpt">< h2>< a href="< ? php the_permalink(); ? >” rel=”bookmark”>< ? php the_title(); ?>< /a>< /h2> < ? php the_excerpt();? > < p class="archive-link">< a href="< ? php the_permalink(); ?>” rel=”bookmark”>read more< /a>< /p> < /div>< !-- ends archive excerpt -- > < div class="clear">< hr/>< /div> < ? php endforeach; ? >
can control:
- category
- number of posts
- sort