WordPress.org

Ready to get started?Download WordPress

Forums

Display Posts Only In Category x? (2 posts)

  1. twilitegxa
    Member
    Posted 2 years ago #

    I have the following code:

    <?php
    if (is_page()) {
      $posts = get_posts ("showposts=12");
      if ($posts) {
        foreach ($posts as $post):
          setup_postdata($post); ?>
          <div style="border: 2px solid #ebebeb; width: 210px; float: left; margin-right: 25px; margin-bottom: 25px; padding: 5px;">
    <h4 style="font-size: 14px; font-weight: bold; padding-bottom: 10px;"><?php the_title(); ?></h4>
    <div style="float: right; padding-left: 5px;">
    <?php the_post_thumbnail(); ?>
    </div>
    	<span style="font-size: 12px;"><?php the_content(); ?></span>
    	</div>
        <?php endforeach;
      }
    
    }
    ?>

    How can I make the posts display that are only in the category named "Training Summary" (slug "training-summary")? Any help would be greatly appreciated!

  2. Just use an array like the first example on this page:

    http://codex.wordpress.org/Template_Tags/get_posts

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.