Title: Recent posts, static page, themed?
Last modified: August 19, 2016

---

# Recent posts, static page, themed?

 *  Resolved [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/)
 * Does anyone know what php code is required to show the top 5 recent posts on 
   a static page, but be themed the same as the standard “Blog” page. I’m using 
   mystique and I would like to create a static page that has top 5 recent posts
   displayed under static content. All tutorials I’ve seen just give the recent 
   posts without any theme, just text! Does anyone know how to do this?
    Just to
   make sure I’m describing it correctly.. Basically I just need help inserting 
   static information above the post “Under Development” located at [http://lostmodernist.com/](http://lostmodernist.com/)
   Whereas the static information will remain static, but the posts below can always
   be changing. Any help!?

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679223)
 * Have you tried setting the 5 posts to ‘sticky’? That should make them show up
   at the top.
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679263)
 * That isn’t what I’m trying to do. I’m trying to display static content above 
   the recent posts.
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679264)
 * Can no one answer this? It seems like an easy thing to do! 😛
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679275)
 * The problem is that the exact answer depends on your theme. It will probably 
   involve coding a secondary loop above the main loop. The tutorials should show
   you sample code that would be inserted above the main loop.
 * At the moment, I can’t see anything on your site except ‘This site will be coming
   soon’, so I can’t tell what theme you are using. If it is a free theme, I might
   be able to give more specific help once I can look at the code. If it is a paid
   theme, you will need to contact the theme supplier for help.
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679278)
 * The website was taken offline so we can get all the backend stuff done before
   launch. It was the Mystique theme. I would just like to be able to either:
    1.
   Insert code into the post page to be able to specify php/html code, i.e. display
   static information above the normal recent posts page or 2. Insert code onto 
   a static page that displays mystique themed recent posts with excepts, author,
   title.
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679280)
 * Code inside posts is not usually executed, only code in templates. You can install
   a plugin such as [Exec-PHP](http://wordpress.org/extend/plugins/exec-php/), but
   that involves disabling the Visual editor in WordPress.
 * Is your ‘normal recent posts page’ a true static page? If so, you probably need
   to change the template as I described in my earlier response. The template is
   probably page.php.
 * If the ‘normal recent posts page’ is the ‘blog’ page, the template is probably
   index.php.
 *  [Chinmoy](https://wordpress.org/support/users/chinmoy/)
 * (@chinmoy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679281)
 *     ```
       <?php wp_reset_query();
        query('showposts=5');
        while(have_posts()): the_post();
        // put here post stuff 
   
        endwhile;
       ?>
       ```
   
 * Try once.
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679293)
 * No, I’m trying to get the normal recent posts page to be static but I don’t know
   how to display the recent posts code on a static page, being themed. I’ll try
   chinmoy’s idea but I’m pretty sure it will just display text, with no themes..
   I.e.
    Title 1 Short excerpt blah blah title 2 short excerpt blah blah
 * With no theme (header being in a box, large font, author name in italics, etc).
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679296)
 * OK. Start with a copy of index.php named front-page.php. Then change the first
   few lines from this:
 *     ```
       <?php
        /* Mystique/digitalnature */
        get_header();
       ?>
       ```
   
 * to this:
 *     ```
       <?php
       /*
       Template Name: front-page
       */
        /* Mystique/digitalnature */
        get_header();
       ?>
       ```
   
 * Change these lines from this:
 *     ```
       <?php
              if (have_posts()):
               while (have_posts()):
       ```
   
 * to this:
 *     ```
       <?php
              query_posts('posts_per_page=5');
              if (have_posts()):
               while (have_posts()):
       ```
   
 * Create a blank Page and assign the new front-page template to it.
 * In Admin->Settings->Reading, choose ‘Front page displays:’ ‘A static page’ and
   set your new page in the dropdown box. Save the changes and you should be done–
   a static front page that displays the 5 latest posts.
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679303)
 * This seems to be a step in the right direction! I have added the code and the
   posts show up, however, my static content that I entered into the page editing
   screen in the admin panel does not show up.
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679304)
 * I tried it the other way: Add a page in the admin menu, leave as default template,
   installed Exec-PHP and inserted the following code to the page:
 * >  This is the test home static information! Above!
   >  <?php query_posts(‘posts_per_page
   > =5’); while (have_posts()): the_post(); mystique_post(); endwhile; ?> Below!!
 * And now the page looks like this:
    [http://lostmodernist.com/wordpress/?page_id=4](http://lostmodernist.com/wordpress/?page_id=4)
   Close, but I’m not quite sure what’s happening to make it display like that.
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679305)
 * [http://lostmodernist.com/wordpress/?page_id=6](http://lostmodernist.com/wordpress/?page_id=6)
   
   Test Home 2 Displays this frontpage.php script. As you can see, there is no static
   information present (static information was inserted to the page via admin panel,
   page publish)
 * >  <?php
   >  /* Template Name: 2 columns page (right sidebar, default) (mod) */ /*
   > Mystique/digitalnature */ get_header(); ?>
   >  <!– main content: primary + sidebar(s) –>
   >  <div id=”main”> <div id=”main-inside”
   > class=”clear-block”>
   >  <!– primary content –>
   >  <div id=”primary-content”> <div class=”blocks”> <?
   > php do_action(‘mystique_before_primary’); ?> <?php query_posts(‘posts_per_page
   > =5’); if (have_posts()): while (have_posts()): the_post(); mystique_post();
   > endwhile;
   >  mystique_pagenavi();
   >  else: ?> <h1 class=”title error”><?php _e(“No posts 
   > found”,”mystique”); ?></h1> <p><?php _e(“Sorry, but you are looking for something
   > that isn’t here.”,”mystique”); ?></p>
   >  <?php endif; ?>
   >  <?php do_action(‘mystique_after_primary’); ?> </div> </div
   > > <!– /primary content –>
   >  <?php get_sidebar(); ?>
   >  </div>
   >  </div> <!– /main content –>
   > <?php get_footer(); ?>
 *  Thread Starter [macatticus](https://wordpress.org/support/users/macatticus/)
 * (@macatticus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679308)
 * I finally nailed it down.. Whew!
    Using a standard template, I needed to download
   a php execution plugin. After that, I can enter in PHP code directly in the admin
   page editor. Putting in the following code yields the results shown here (static
   information shown both below and above recent post content) [http://lostmodernist.com/wordpress/?page_id=4](http://lostmodernist.com/wordpress/?page_id=4)
 * > This is the test home static information! Above!
   > <?php
   > query_posts(‘posts_per_page=5’);
   >  while (have_posts()): the_post(); mystique_post();
   > endwhile; wp_reset_query(); ?>
   > Below!!
 * vtxyzzy, your code helped me understand what needed to be injected into the post.
   The only thing I was missing earlier, when my page was displaying multiple posts
   of the same thing, was the wp_reset_query(); command. All is well. I hope this
   can help out someone else in the future!

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

The topic ‘Recent posts, static page, themed?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 13 replies
 * 3 participants
 * Last reply from: [macatticus](https://wordpress.org/support/users/macatticus/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-static-page-themed/#post-1679308)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
