<?php if ( get_field( 'category_slug_name' ) ): ?> <h1 class="page-title"><?php the_field('feed_list_title'); ?></h1> <ul> <?php global $post; $args = array( 'numberposts' =>get_field('number_of_excerpts'), 'offset'=> 0, 'category_name' =>get_field('category_slug_name'), 'orderby' => 'post_date', 'order' => 'DSC'); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li> <div class="clear"> <div class="feed-thumbs"> <a href="<?php the_permalink(); ?>" rel="bookmark"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail('medium'); } else { ?> <img src="<?php bloginfo('template_directory'); ?>/images/default_thumbnail.jpg" alt="<?php the_title(); ?>" /> <?php } ?> </a> </div><!--ends 4-thumbs --> <div class="feed-excerpt"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php the_excerpt();?> <p class="archive-link"><a href="<?php the_permalink(); ?>" rel="bookmark">read more</a></p> </div><!-- ends front-excerpt --> </div><!-- ends clear--> </li> <hr/> <?php endforeach; ?> </ul> <?php else: // field_name returned false ?> <!--if no entry in field query will show posts unfiltered by category --> <?php // the query $wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>6)); ?> <h1 class="page-title"><?php the_field('feed_list_title'); ?></h1> <ul> <!-- the loop --> <?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?> <li> <div class="clear"> <div class="feed-thumbs"> <a href="<?php the_permalink(); ?>" rel="bookmark"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail('medium'); } else { ?> <img src="<?php bloginfo('template_directory'); ?>/images/default_thumbnail.jpg" alt="<?php the_title(); ?>" /> <?php } ?> </a> </div><!--ends 4-thumbs --> <div class="feed-excerpt"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php the_excerpt();?> <p class="archive-link"><a href="<?php the_permalink(); ?>" rel="bookmark">read more</a></p> </div><!-- ends front-excerpt --> </div><!-- ends clear--> </li> <hr/> <?php endwhile; ?> <!-- end of the loop --> </ul> <?php endif; // end of if field_name logic ?> <?php wp_reset_postdata(); ?>