Title: wordpressnoob's Replies | WordPress.org

---

# wordpressnoob

  [  ](https://wordpress.org/support/users/wordpressnoob/)

 *   [Profile](https://wordpress.org/support/users/wordpressnoob/)
 *   [Topics Started](https://wordpress.org/support/users/wordpressnoob/topics/)
 *   [Replies Created](https://wordpress.org/support/users/wordpressnoob/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/wordpressnoob/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/wordpressnoob/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/wordpressnoob/engagements/)
 *   [Favorites](https://wordpress.org/support/users/wordpressnoob/favorites/)

 Search replies:

## Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Make posts from certain category display on page other than the main](https://wordpress.org/support/topic/make-posts-from-certain-category-display-on-page-other-than-the-main/)
 *  [wordpressnoob](https://wordpress.org/support/users/wordpressnoob/)
 * (@wordpressnoob)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/make-posts-from-certain-category-display-on-page-other-than-the-main/#post-516135)
 * How did you get this to work?
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [Page Template: Posts by category](https://wordpress.org/support/topic/page-template-posts-by-category/)
 *  Thread Starter [wordpressnoob](https://wordpress.org/support/users/wordpressnoob/)
 * (@wordpressnoob)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/page-template-posts-by-category/#post-559226)
 * I can’t make the examples work. If you know how to do what I am trying to accomplish,
   why not post the solution or point me to an example that will work?
 * The reason I am going through a struggle, is because I am trying make something
   work based on the web examples. Maybe you can make them better, so people like
   me would understand them.
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [Page Template: Posts by category](https://wordpress.org/support/topic/page-template-posts-by-category/)
 *  Thread Starter [wordpressnoob](https://wordpress.org/support/users/wordpressnoob/)
 * (@wordpressnoob)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/page-template-posts-by-category/#post-559212)
 * Well I nearly have it working, the only problem I am no having is the formatting.
   It correctly pulls the posts that are of the category “Recipies” and displays
   them on the page “Recipies”
 * The only annoying thing is that they are below the sidebar. Thanks for the help,
   maybe this code will help someone else do this.
 *     ```
       <?php
       /*
       Template Name: category-3.php
       */
       ?>
   
       <?php get_header(); ?>
       <?php get_sidebar(); ?>
       <div id="content" class="widecolumn">
   
       <!-- Start the Loop. -->
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   
       <div class="post">
       <?php
        $myposts = get_posts('category=3');
        foreach($myposts as $post) :
        ?>
       				<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
       				<small><?php the_time('l, F jS, Y') ?></small>
   
       				<div class="entry">
       					<?php the_content() ?>
       				</div>
   
       				<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
   
       			</div>
        <?php endforeach; ?>
   
        <!-- Stop The Loop (but note the "else:" - see next line). -->
        <?php endwhile; else: ?>
   
        <!-- The very first "if" tested to see if there were any Posts to -->
        <!-- display.  This "else" part tells what do if there weren't any. -->
        Sorry, no posts matched your criteria.
   
        <!-- REALLY stop The Loop. -->
        <?php endif; ?>
       <?php get_footer(); ?>
       ```
   
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [Page Template: Posts by category](https://wordpress.org/support/topic/page-template-posts-by-category/)
 *  Thread Starter [wordpressnoob](https://wordpress.org/support/users/wordpressnoob/)
 * (@wordpressnoob)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/page-template-posts-by-category/#post-559205)
 * Ok, this is getting closer and closer. I used some code from the website and 
   changed a few things around. I’m still alittle confused though.
 * I went and renamed the file to “category-3.php” and put the following inside 
   as well…
 *     ```
       <?php
       /*
       Template Name: category-3.php
       */
       ?>
   
       <?php get_header(); ?>
       <?php get_sidebar(); ?>
   
       <div id="content" class="widecolumn">
       <ul>
        <?php
        $myposts = get_posts('category=3');
        foreach($myposts as $post) :
        ?>
           <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> --- <?php the_excerpt(); ?></li>
        <?php endforeach; ?>
        </ul>
       ```
   
 * **Do I need to query the database before I start this loop? Is that why this 
   is working?**
 *     ```
       <!-- Start the Loop. -->
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   
        <!-- Display the Title as a link to the Post's permalink. -->
        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
   
        <!-- Display the Time. -->
        <small><?php the_time('F jS, Y'); ?></small>
   
        <!-- Display the Post's Content in a div box. -->
          <?php the_content(); ?>
   
        <!-- Display a comma separated list of the Post's Categories. -->
        <p class="postmetadata">Posted in <?php the_category(', '); ?>
   
        </div> <!-- closes the first div box -->
   
        <!-- Stop The Loop (but note the "else:" - see next line). -->
        <?php endwhile; else: ?>
   
        <!-- The very first "if" tested to see if there were any Posts to -->
        <!-- display.  This "else" part tells what do if there weren't any. -->
        Sorry, no posts matched your criteria.
   
        <!-- REALLY stop The Loop. -->
        <?php endif; ?>
       </div>
   
       <?php get_footer(); ?>
       ```
   
 * It looks really close (sample output to follow):
 *  * smelly chicken —
    * Gross chicken —
 * Recipies
    May 3rd, 2007
 * Posted in Uncategorized
 * I just want the smelly chicken and the gross chicken to come after the Recipies
   header.

Viewing 4 replies - 1 through 4 (of 4 total)