I apologize if this is a newbie question, but I am very new to working with WP template files.

I am working on a campaign site (that I unfortunately can't show you before the launch in a couple weeks). I'm using a static home page, and I've managed to create a template that displays posts (title, date, excerpt) below the static content. Now I'm working on the issues page and I would love to be able to put dynamic post data within the static content.

To illustrate here's some dummy content:


we have to make jobs blah blah

For more on my stand on the economy, go to my blog:

[insert three most recent posts in the "economy" category here]


Go green, blah blah blah

For more on my stand on the environment, go to my blog:

[insert three most recent posts in the "environment" category here]

So, is this possible? I tried creating a new template and writing the static content directly into the php file and then for each section from the blog using the same code I used on the home page except with an extra query element for category. That didn't work.

Any ideas? I can't find anything like this on any forums, or any example websites really. It would be AWESOME if this is relatively easily possible, but if not it wouldn't be the end of the world to just add manual links to the page as we write more posts.

Thank you so much!!

2 Answers 2


Maybe take a look inside the 2010 theme that comes packaged with WP, index.php shows a call to a loop file: <?php get_template_part( 'loop', 'index' ); ?> so you could (well this is how i would do it, cos i think it looks neater, but you could use multiple loops) create 2 new loop files for example they could be called loop-economy.php and loop-enviroment.php both of these loops set to call only posts from there respective categories and then use:

<?php get_template_part( 'loop', 'economy' ); ?>

where you want the economy posts to show in your template and then use:

<?php get_template_part( 'loop', 'environment' ); ?>  

where you want the environment posts to show in your template

  • Sounds promising, where would I put the static content though? Is it possible to use a call like that in the WP in-browser page editor?
    – Claire
    Jun 17, 2011 at 19:52

I'd create a page, and put in your text content "Economy...we have to make jobs blah blah". Make a new page template, and apply it to your page. Then keeping the normal page content, add in a call to get_posts to display your posts underneath.

Then your text above is editable, and your posts from the category are shown...

Template Name: My Template

get_header(); ?>
    <div id="content">
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <div class="page">
            <?php the_content(); ?>

    global $post;
    $myposts = get_posts('numberposts=-1&category=1');
    foreach($myposts as $post) :
        <div class="post">
            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <?php the_content();?>
    <?php endforeach; ?>
    <?php get_sidebar(); ?>
<?php get_footer(); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.