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:
Economy
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]
Environment
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!!
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 calledloop-economy.php
andloop-enviroment.php
both of these loops set to call only posts from there respective categories and then use:where you want the economy posts to show in your template and then use:
where you want the environment posts to show in your template
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…