To follow this specific example, you would create pageofposts.php inside the template folder. Since you’re now making changes to the theme, you should create a child theme of twentyeleven first:
http://codex.wordpress.org/Child_Themes/
To just get a page containing all posts, you don’t need to do anything that complicated. Your front page already displays your latest posts. You can instead have it display any Page as a front page, and choose another page for the Page of Posts. To do that (from the Dashboard):
1. Go to Pages->Add New, and create a new empty page. I often call it Blog or News. This will be the “Page of Posts”
2. Repeat 1 to create your front page, if needed.
3. Click General->Settings.
You’ll see the option “Front page displays:”. Select “A static page (select below)”. Then set the Front page to your front page (step 2), and your Posts page to the page you created in step 1.
Hope that helps!
Thank you for the help.
I have created a child theme as directed.
I want my home page to display ALL new posts stickied to the home page.
I have the following Categories: Aquariums, Mice, Art and Snake.
These are also pages.
I want the Aquarium page to show all posts under the category aquarium and so forth.
I will try what you have said and see if it works this way.
I am having problem with this step:
Go to Dashboard › Themes and activate your new theme, the Twenty Eleven Child.
I have created the folder in the directory where the style.css file is.
When I go to themes I do not see where I can activate the new child theme.
Current Theme: Twentyeleven Child
I was able to activate the new Child Theme.
I also got the page of posts to work here: http://www.termato.net/aquariums/20g-community/ for two categories.
Is these a way I can also put content on this page. When I go into the editor on the admin side and to Edit Page, the content in the content box is not on the page.
I am guessing I will need to take the variable for this content and put it on the template for the pageofposts?
assuming that your pageofposts has a custom query somewhere, add a simple loop before the custom query;
http://codex.wordpress.org/The_Loop
example:
<?php while( have_posts() ) : the_post(); ?>
<div class="page-content">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
that should output the actual content as added into the page editor.
details depend on the existing code of your pageofposts template;
you can paste the full code into a pastebin.com and post the link to it here if you would like someone to have a look at it – HOWTO
Thank you for the quick response alchymyth.
I literally copied this code:
http://codex.wordpress.org/Pages#A_Page_of_Posts
I added the concluding ?> that is missing and changed the category names.
try to add my suggested code just before those lines:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'category_name' => 'antiquarianism, championship', // Change these category SLUGS to suit your use.
'paged' => $paged
);
query_posts($args);
Thank you so much.
That really helped and it worked well. See here
The only thing I do not understand about this code is why it is in a while loop?
<?php while( have_posts() ) : the_post(); ?>
<div class="page-content">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
I can see it is calling “the_content();” function but why is it in a loop?
That will only show the content if there are posts present. If I want the content to show regardless I would exclude that code.
I personally do use the default syntax for a loop, even if it is only one post/page;
however, being just one post/page, you possibly could get away with:
<?php the_post(); ?>
<div class="page-content">
<?php the_content(); ?>
</div>
try it 😉