How to: Add Posts to Pages in WordPress [Tutorial]

March 4, 2011    92 Comments

How to Add Posts to Pages in WordPress Tutorial

Adding Posts to your WordPress Pages is handy for driving traffic to your blog from pages on your site.

If you’re trying to add posts to pages in your WordPress website, this how to guide is for you.

Maybe you want to add posts to the bottom of your pages… or maybe you want to put them in the middle of your pages.

You probably want to only add certain posts to certain pages, and you want a way to specify which posts goes on which pages.

Your goal might be putting specific posts on a page other than your home page.  That is, adding a certain set of posts to a page that is NOT your homepage, or “posts” (or “blog”) page.

If one of those situations apply to you – this tutorial is for you. (skip down to the tutorial)

A quick aside: There is going to be a lot of talk on posts and pages…
if you don’t know the difference – read about WordPress SEO & Posts vs Pages










How to: Add Posts to Pages in WordPress

To my knowledge, there is no “easy” way to do this – you’re going to have to get in the code (for some people, this is exciting).

You will need to have some knowledge (or not be afraid to dabble and mess with) of: HTML, PHP, WordPress file structure (specifically, how themes work & FTP), and WordPress in general (administration, adding categories, editing pages, writing new posts and putting them in certain categories).

If you want to make the posts that will appear on your pages “look pretty” (or look consistant with the rest of your website) – you will need to be comfortable playing with CSS as well.

IF any of that stuff above scares you, I recommend NOT reading this and asking us for help.

Otherwise – let’s add posts to pages in WordPress!

Here is a simple outline, or table of contents if you will, of the steps we will be taking.

  1. Make a new custom page template
  2. Make a new post category (or use an existing one)
  3. Add code to the new page template
  4. Change a page to run on the new page template
  5. Add a new post to the new (or chosen) category
  6. Check to make sure it works & Ta-Da!

For this “how to” – I’m going to use an example: Suppose you have a page on your website called Stories and you want to add posts under that page.  Each post will be a stand alone “story”, and the collection of all these posts will live under the page called Stories.

Let’s get to it.

1. Make a New Custom Page Template

We are going to create a new set of code for WordPress to execute when the visitor is viewing the page that we want our posts to appear on.

Adding a customized page template is easy… check out WordPress page templates codex.  Don’t worry, I’ll give you the quick step by step for you now:

Look in your theme folder for page.php – did you find it?  If not, open index.php instead.

Copy the contents of that file into a new file called page-stories.php.

At the VERY TOP of that file, add this code:

<?php  /* Template Name: Stories */ ?>

Congratulations, you’ve added a new page template to your WordPress theme. Yay! – BUT: this page template does nothing different than the default page template because we didn’t change any code (yet).

OK – keep that new page (page-stories.php) open for now – we will come back to it really shortly.

2. Add a New Category (or chose an existing one)

Let’s add a new category called, you guessed it, “Stories”.

If you already have a category that has a bunch of posts in it and you want to pull posts from that category onto a certain page, we can do that too.

All you really need is to grab the ID of the category you want to use.

To do this, click on the category of choice as though you were going to edit it.  This will open the category edit (or “detail”, as I like to call it) page.

Look at the URL in your address bar and find the number that comes after tab_ID=.

Get Category ID in WordPress

Finding the category’s ID

In this case, our category ID is 38 — write that down, remember it, we will need it very shortly.

3. Add Code to Custom Page Template

This is the critical step in adding posts to pages in WordPress.

Remember that custom page template that we created earlier?  We called the file page-stories.php … you kept that file open right?

Here is the tricky part.  It’s tricky because you have to understand what the code is doing to be able to place this next piece of code in the right place.

I will do my best to explain:

This next piece of code that you’re going to add to your custom page template is going to look for posts in a certain category and output them onto the page.

In this example, we are going to put the posts AFTER the page content.

Important Note: You cannot put this code in the middle of the WordPress loop.  It won’t work.  You MUST put the code outside of the first loop.  See the picture below:

WordPress Page Template Code Loop

Put the code (found below) in the highlighted area — AFTER the ending of the first WordPress loop

Here is the code to put into your custom page template.
Remember, the template is called “Stories” and the file is page-stories.php.

<br />
<?php<br />
global $more;<br />
$more = 0;<br />
query_posts('cat=38');<br />
if(have_posts()) : while(have_posts()) : the_post();<br />
?></p>
<p><a href=&amp;quot;<?php the_permalink(); ?>&amp;quot;><?php the_title( '</p>
<h3>', </h3>
<p>' ); ?></a></p>
<p><?php<br />
endwhile;<br />
endif;<br />
wp_reset_query();<br />
?><br />

Please Note: See in the second line it says cat=38?  That 38 is the tab_ID that we found in the URL of the category editing page earlier (I didn’t tell you to remember it for nothing).

So you want to change that cat=38 to the tab_ID of the category that you found, make sense?

Update (11-29-12): Added the global $more variable & set it to zero.. this is to ensure the “read more” functionality works.

That should add posts in that category to the page that runs the template we created earlier.  But first you have to tell the page to run that template…

4. Update a Page to Run the Page Template

Do you know which page you want to add posts to?  If so, navigate to editing that page… otherwise, add a new page.

Underneath the big blue “Publish” button, there should be a section called “Page Attributes” — find this.

One of the page attributes is “Template”.

Change your page template to “Stories” and re-publish your page.  Make sure you check the page to make sure nothing is broken.

Change Page Template WordPress

Change the page template of the page you want the posts to show up on

That was an easy step :) – The next one should be too.

5. Add a Post to the Chosen Category

I hope that headline is self-explanatory… but make sure you add the post to the category that you’re using to pull posts onto the page.

Yes, you CAN put the post in multiple categories, just as long as one of them is the category that you chose earlier.

If you chose a category that already had posts in it, you can skip this step and move onto…

6. Check to Make Sure it Works & TA-DA!

Did you successfully add posts to your WordPress page?

All you have to do to check to see that it’s working is refresh the page that you chose to display posts on (that which you changed the template of in step #4 above.

Here is a before and after of my blog after following the steps above.

Before & After of adding posts to pages in WordPress

Before & After

That’s it.  If you successfully followed this tutorial, you have added posts to pages in WordPress.

If you run into any problems or just can’t seem to ass posts to pages, there are several next steps you could try:

  1. Try again.
  2. Comment below – someone else might have the same problem and your comment could help them solve it!
  3. Click here to contact us – we do this stuff in our sleep and are always happy to help!

Until next time, this is Arsham signing out :)



Written by: Arsham Mirshah (79 Articles)

WebMechanix co-founder, technical SEO, Google analytics junkie, & web dev'r who loves to ski, play tennis and demonstrate ROI.

Follow Arsham on Twitter    
  • http://socialfulcrum.com/social-media-and-word-of-mouth-marketing-services-from-social-fulcrum/ Andrew

    I’ve used the Associated Posts plugin and I find it a great way to have a gallery-esque view of posts on a certain page. I use it for our services page: http://socialfulcrum.com/social-media-and-word-of-mouth-marketing-services-from-social-fulcrum/

    • http://www.seobywebmechanix.com Arsham Mirshah

      Yes, yes! That plugin is money…

      The method described above is a dynamic approach, so you don’t have to go to the plugin and add new posts each time you add one.

  • chiko

    It doesnt wotk in my site.
    seems that the post doen’t appear under the page.

    the code :
    query_posts(‘cat=38′);so I have to change it like this ?query_posts(‘cat=tab_id’);

    thanks

  • http://www.seobywebmechanix.com Arsham Mirshah

    So does it ultimately work?

    Some themes are different in that they already do a query_post() to populate some other area of the site… in those cases you have to use a wp_reset_query() before your query_posts().

    • Junaid

      Hi, it works perfect. I have a problem though.. The page for now is showing me short paragraph of page content and showing me full content of post.. What i need is totally oposite. I need to show full content of page and then posts having short discription with Read More link.. is it possible?
      Please help soon.Thanks 

      • http://www.seobywebmechanix.com Arsham Mirshah

        Yes, this is very possible. I don’t see why it would change anything to the page content — could you send me a link to the page that you are working on? (fill out our contact form and say attn: Arsham)

        As for the posts showing a short description :: You can either use the_excerpt() (instead of the_content()) OR see this page (below) for how to use the tag. Use the MORE tag to tell WP where to cut off the preview content and link to the full post.

        http://codex.wordpress.org/Function_Reference/the_content

  • http://pl-underground.com/ Admin

    Thank you for posting this tutorial!!! I’m not familiar with php at all. However this tutorial plus a few minutes on http://www.w3schools.com/php/default.asp helped me make a “page of posts” AND tweak it to work with the wordpress theme I’m using.

    XOXO,
    P.L.

    • http://www.seobywebmechanix.com Arsham Mirshah

      That would be my pleasure P.L. – glad it could help… feel free to share your excitement with others :)

  • Sharon

    I understand how to add the content, but you have lost me with creating a new file first  (Copy the contents of that file into a new file called page-stories.php.) can you please advise me how to create this new file?
    Thanks for your help, Sharon

    • http://www.seobywebmechanix.com Arsham Mirshah

      Sharon, it would be my pleasure to help you.

      You want to copy the contents of page.php into a new page called “page-SOMETHING.php” — You will need an FTP program (like FileZilla or PSPad or DreamWeaver) to do this.

      Are you familiar with FTP Sharon?

      I can help you accomplish this if you’d like… let me know.

  • George Ivanoff

    Brilliant! Many thanks.  I’ve just used this tutorial for my site and it all works wonderfully. One question, though. Now that I have posts with a certain category displaying on a particular page, is there any way of stopping those posts from also appearing on the homepage with all the other posts?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Ah, happy to hear this George!

      There certainly is a way to accomplish this… but it depends on how your theme is set up.

      Look for a file within your theme directory called home.php — if that exists, it likely runs your homepage. Otherwise, it’s probably index.php that it running your homepage.

      Step 1: Find the file running your home page
      Step 2: Make sure that file isn’t running any other page (it very well could be)
      Step 3: http://codex.wordpress.org/Function_Reference/query_posts#Exclude_Categories_From_Your_Home_Page

      Let me know if that helps George!

  • Paul

    Hello,
    I am having a problem with doing this. I have added the extra pieces of code and changed to tab_ID=xx.. Firstly my page.php does not look like yours, and after doing everything and going to page attributes in the page that I want to post to, it only gives me 4 options.. Default Template, Archives page, full width, and Sitemap.. There is no option for stories.. Can you maybe contact me for some help?
    Thank you,

    • http://www.seobywebmechanix.com Arsham Mirshah

      Paul – You might be using a Child theme but updating the parent theme… do you know which theme or theme framework you’re using?

  • http://twitter.com/shelly45840 shelly45840

    Is it possible to display multiple categories on a page? If yes, how would I add that to the template?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Yes, it sure is possible. Try a couple Google searches and see what you can’t turn up… I can tell you that it will include the use of the “wp_reset_query()” function.

      Good luck & let us know how you fair… if you want our professional help, please submit our contact form.

  • http://twitter.com/tampabaytek Cory @BayAreaTech

    I’ve already used this trick on several websites, but I now have a question. I want to limit the number of post from a given category to 1 (most recent).  Sort of like displaying a “latest news”, and not all posts from a given category.

    • http://www.seobywebmechanix.com Arsham Mirshah

      You can try using the posts_per_page parameter in your query_posts() call — OR — get rid of the while part of the loop.

  • John

    Hey Arsham, great tutorial, it’s working wonderfully for me.  I have one question:  I have the posts from one given category populating a page nicely, but there are really too many posts in that category for me to want them all showing on one page.  I used the “Reading” settings to limit the number of posts on the page, but I’d like to generate an “Older posts” prompt to load the next group of posts, etc., page by page.  Any suggestions on how to do that?  (I’m using the Atahualpa theme)…

    Thanks!

    • http://www.seobywebmechanix.com Arsham Mirshah

      Hi John, sorry for the delayed response.. hope you had a good Turkey day…

      To be honest, this wouldn’t be very simple. There are 3 options that I could think of:

      1 – Create a new page template that acts like a category page (but only pulls from that category). Set the query to only have 5 posts per page, then wordpress will automatically create the pagination for you. Then you can embed this new page within your page template using an iFrame.

      2 – Load all of the posts in that category and use jQuery to hide all but five. Then have a jQuery tabber that “pages” through the next 5 elements of the list of pages.

      3 – Use jQuery .load() function to use AJAX to grab the next 5 pages.. you would have to create a custom page template that accepts query parameters which load into the WP query that tell it where to start getting posts (I believe it’s ‘offset’)..

      None of these are relatively easy, but it is very possible. Let me know if this helps at all..

      • John.

        Thanks, Arsham!  This season has been hectic, so it took me awhile to get back to checking this page.

        I must admit I’m more in the category of “not afraid to dabble with” than “comfortable with” PHP, jQuery, WordPress file structures, etc.  I think (hope) your suggestions will put me on a track where I can figure out what I need to know, however… I appreciate your feedback!

        John.

  • Roshan Premachandra

    Great tutorial.

  • Miss Elric

    Great tutorial. Worked perfectly on my blog.

    I have a question though. How can I make my posts appear on top of the page instead after the content of the page? Is there a way to do this? Thanks!

    • http://www.seobywebmechanix.com Arsham Mirshah

      There certainly is a way, though maybe more difficult than is able to be written in a tutorial as every theme is different..

      Do you want us to have a look at your particular case? What’s the website you’re looking to accomplish this on?

      • DOS

        Firstly, great tutorial, one of
        the few I didn’t get frustrated and ditch mid way
        through!

         

        I’d also be interested on knowing
        how to make the posts appear at the top of the page. The site is http://www.carrickrugbyclub.ie, I’ve applied
        the new template to the Youth/Minis page under Teams.

         

        Cheers

        • http://www.seobywebmechanix.com Arsham Mirshah

          Because of the way that WordPress loads the page.. you’re going to need a plugin or custom CSS to position that pane above the rest of the content.

          I could do a tutorial for how to do that, if I had more time!

          Thanks for the kind words.

          Check out http://www.theandystratton.com – he knows his stuff when it comes to WordPress.

  • Hitesh Saikar

    How do i access the php file? I have created my blog directly from wordpress.com. I have not installed wordpress using Fantastico or any other tool. Can you please help?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Unfortunately, you cannot access the PHP files that run your wordpress.COM installation.. this only works for self-hosted WordPress instances.. Sorry :(

  • http://twitter.com/sacbiznews sacbiznews

    Hi, thanks for the great information.I know absolutely nothing about this and you taught me perfectly. My only problem is the result I got looks like this: http://www.sacbiznews.com/blog/
    When I want the blog page to look like this: http://www.sacbiznews.com/category/blog/

    I’ve tried copying the page source of the desired page and it worked but it didn’t bring new content in. Any thoughts? I would greatly appreciate it.

  • http://twitter.com/sacbiznews sacbiznews

    Scratch my last post. I got everything working. Thanks :)

    • http://www.seobywebmechanix.com Arsham Mirshah

      Well done! Glad to hear it :)

  • Lisanelsonrd

    Arsham – Thank you! This is along the lines of what I’m looking for. Followed the steps without issue – http://healthpracticesonline.com/liz/how

    However, I’d like for the two most recent blog posts to appear in the middle of a page and to just be the blog post title with a few lines of intro and link to read more.

    Suggestions?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Hey there you’re welcome! Glad it worked for you..

      The method I used will show all the posts in the category. To limit the number of posts you want to show, try replacing “query_posts…” with:

      query_posts(‘cat=38&posts_per_page=2′);

      That will limit the number of posts returned to 2.

      THEN – to get it to show just a few lines (or a summary/excerpt).. replace “the_content(‘Read More’)” with:

      the_excerpt();

      Read up on the_content and the_excerpt here: http://codex.wordpress.org/Function_Reference/the_content … you could leave the code how it is and put a “” in the content of your post to make it cut off and show the read more link :)

      Let me know if I can be of any more help :)

    • http://www.seobywebmechanix.com Arsham Mirshah

      PS if you don’t mind tweeting / sharing this.. I would GREATLY appreciate it :)

  • http://twitter.com/dacotahsgirl Sandy D.

    I have a quick question. ;) At most, I have 4 posts showing on my blog’s home page. I created a page to pull posts from others categories (from your tutorial—thanks!) Is there a way to show more than 4 without changing the amount of posts shown on my “home” page? Thanks!

    • http://www.seobywebmechanix.com Arsham Mirshah

      Hi Sandy D :) — You are welcome, glad it worked out for you.

      See this comment for instructions on how you might accomplish this… let me know via twitter (@webmechanix & @arshammm) if it helps :)

      Otherwise, comment again and I’ll see if I can’t help further.

      CHEERS!

  • Guest

    How would I edit the code so I could change the category by page? I have found this but couldn’t get it to work either on its own or with your code.

    http://wordpress.org/support/topic/add-categories-to-static-page#post-1021153

  • http://www.seobywebmechanix.com Arsham Mirshah

    That’s getting somewhat complicated..

    You COULD make different page template for each category (and just change the “category ID” parameter).

    Or – you could use a custom field to set which category to show posts from on that given page.

    This is definitely getting into more advanced WordPress Development.

    We can certainly do this for you and make it easy to manage, let us know if you’d like that.

  • Tim

    i cant seem to put the code in the right place on my page-x.php file.  wont work for me. hmmmm

    • http://www.seobywebmechanix.com Arsham Mirshah

      Not all WordPress installations are made equal… good luck Tim, let us know if we can help.

  • Andrew

    Thanks Arsham.  I was able to make these changes and get everyting working, but the posts are all bunched up.

    On my normal blog page there are blank lines and solids lines that seperate all of the posts.  But on the re-directed post-page there is no seperation or anything; they are all bunched up, line after line.  Any ideas?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Sounds like a CSS issue my friend.. try viewing what CSS makes the blank space and solid line and replicate that on your post output.

      • Andrew

        Thanks, I got it figured out!!  I “borrowed” a little code from the single.php and worked it into your code and now it looks perfect!

        • http://www.seobywebmechanix.com Arsham Mirshah

          Good stuff Andrew, glad you got it working!

  • http://www.facebook.com/people/David-Willoughby/1114792971 David Willoughby

    You rock!

  • Elnaz Sarraf

    Hello,

    This is a great post, Can you tell me how I can add post featured images (thumbnails) next to the post? I appreciate your help.

  • John

    I have managed to do this and the posts are appearing in the page I want, however, the posts are still sppearing on the home page which I don’t want, is there a way to exclude the newly created category posts from the home page? Thanks.

    • http://www.seobywebmechanix.com Arsham Mirshah

      Absolutely.. You want to find the template file that’s running the home page and modify that to not include the category IDs.

      I think the same query_post function will work but you put a negative category ID .. Or just include the categories you want.

      Good luck and let me know how it goes!

      • Brett

        Would you know what the file name could be for the home page?

        • http://www.seobywebmechanix.com Arsham Mirshah

          Generally, index.php runs your homepage.. but it could also be called: front-page.php, home.php, or page-home.php —

          Actually, it could be called anything really.. the best way to find out is to:
          — Go to edit the homepage
          — See which page template it’s running on
          — Find the matching page template by searching through files

          Another method: search around for a plugin that prints which php file is running a particular page. That is, when the plugin is turned on, when you visit any page of your site, it will print which files are being used.
          Let me know if this helps.

  • Cinco

    Sweeet – trying to create a customised blog page, really help – thanks

  • Rahul R

    Did everything you said and got it WORKING!, BUT

    At the starting of this tutorial you said “You probably want to only add certain posts to certain pages, and you want a way to specify which posts goes on which pages.”

    And this is my problem. I need this technique for my web portfolio where I can create client wise pages showing all categories of services I did for them (posting different services using your technique) and also want to show works in category wise.

    Now all the posts I add, is coming under the page I created even I meant to post a work that should come under another client page. its happening just because its under the category I had created as you said.

    I want to decide which posts would should be shown in a particular page.

    Can I expect your help bro?

    • http://www.seobywebmechanix.com Arsham Mirshah

      In this model, the only way to decide which posts hit which pages is by grouping them in categories.

      If you want multiple categories to come up on 1 page, you’d simply copy & paste the code that pulls a particular category and change the category number.

      But really, it sounds like you want to control which posts show up on which pages more explicitly than just via category groupings… In which case, you’re looking at some custom development.

      Without fully understanding your case, I would think something like the “advanced custom fields” plugin is needed.. that plus some custom template development will provide your solution.

      Sorry if that wasn’t helpful.. maybe if I better understood your situation..

      Either way, let me know what happens & best of luck!

  • http://www.facebook.com/yves.gallego Yves Gallego

    First THANKS A LOT for that great Tuto !!!
    Everything works fine as in your example !
    However, I would bring up the date and time next to the title of the article content on the page … Is it possible? if so, how to please?

  • Michal

    Thank you very much, I was thinking about this way of solving the problem, but I am not php savvy and you saved my day:) I really do not know why this is not natively in WP software. I am new to WP and last few days I have spent cursing myself for not being able to solve it, then I realized.. Why on earth is there only one “posts” page, while you can create as many static pages as you wish? (I know, it is blog..but still WP has certainly more aspirations than to be simple “post after post after post” cms) It seem to me to be the main obstacle when creating a website with more traditional structure in mind – most people want their content nicely divided from the beginning. Handling it using categories is not so good, when you do not have all kinds of content, but few.

    • http://www.seobywebmechanix.com Arsham Mirshah

      Hey, glad this helped! Let me know what other challenges you’re facing because chances are others are facing the same challenges and I’d be happy to write up a how-to tutorial type article to help.

      PS: Don’t be shy to tweet or like our facebook page :)

  • http://www.facebook.com/someloveitsomehateit You Need

    Hi Arsham Great tutorial helped me and easy to do it
    Just a one Question Please
    if i want to make more categories which allows me to make my posts appears on different pages on my website do I have to do the same create a page with the index.php code and paste the

    above …. ?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Thank you. Yes, with this model, you would have to create a new template file for each category of posts that you want to pull onto the page.

      Let me know if that helps.

      • http://www.facebook.com/someloveitsomehateit You Need

        Thank You Very Much Arsham Works like a charm thank you again (:
        Regards

        • http://www.seobywebmechanix.com Arsham Mirshah

          Sweeeet! Happy to hear that Zak!

  • sam

    Hi, this has helped me a lot but I run into a small problem. I would like to have the posts on a static front page just 2 posts which is fine but the are not appearing on the page but just dropping below with the normal sequence of posts. How can this be avoided?

    • http://www.seobywebmechanix.com Arsham Mirshah

      The template file that’s running your front page must have a WordPress “loop” running above your code which is outputting all those posts.

      You can try either removing that code.. OR, probably better yet…

      From the WordPress admin backend, go to Settings -> Reading and switch the “Front page displays” settings :)

      • sam

        Hi,

        Thanks for your reply. Front page displays is not doing anything removing yes but then I end up with only 2 posts so I suppose I have to call then then the rest of the posts which i would like to show on the front page? Will I not have any trouble down the road since I will be having an empty page.php? Sorry to ask so much but I have been struggling for 2 days with this lol you are my savior…

        • http://www.seobywebmechanix.com Arsham Mirshah

          Well I wish I could help, but without understanding your specific situation and seeing your code, it’s going to be hard for me to help.

          I might suggest looking around for a plugin that might help you accomplish what you’re trying to do.

          OR – if you have the funds, finding a WordPress developerwho can help you.

  • Adam Gorecki

    Thanks Arsham. This is a great tutorial for a beginner like me. I have spent two days trying to solve this problem, but your’s was the best solution.

    I am wondering if there is a way to show each post in a different “box” (similar to the default blog page). I am assuming it is some CSS. What code would I use to be able to do this?

    My other issue is that there is no place for people to comment on the individual posts. However, when I click on the post name, it brings me to a page where comments are allowed. It seems as though the template created by your tutorial just does not allow for comments on the individual posts. Any advice?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Thanks for the kind words.

      Yup, you will need some CSS love to make the different boxes happen. Shouldn’t be too bad :)

      You might be able to do a comment template in the loop that puts the posts onto the page: http://codex.wordpress.org/Function_Reference/comments_template

      Hope this helps

  • Stephane Roch

    Hi, I downloaded your pluging and it does exactly what I want. Thank you. I spotted that there is no space between the post-ID and the “Read more…” text. I found where to fix it if you want to include in your next revision:

    if($displaySequenceItem==”readmore”){

    if($boolFlags[“show_readmore”]){

    $html .= ”;

    $html .= ‘ID) . ‘”>';
    //change is below added space.
    $html .= ‘ ‘ . $dataFlags[“text_readmore”];
    // end of change
    $html .= ‘
    ‘;

    $html .= ” . PHP_EOL;

    }

    • http://www.seobywebmechanix.com Arsham Mirshah

      a
      pprove

  • Jason Mills

    Thanks so much for this, it really was the clearest solution I’ve found.
    I was able to make the page and populate it with the right posts, but…

    All the posts are lined up right against the left edge of the page. Is there a way to move everything over?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Jason, thanks for the kind words..

      Do you know CSS at all? You could wrap the posts in a , give it a class, and set that class to have a margin-left of 20px.

      Try this:

      Put ” before the code block (before “global $more”)
      Put ” at the end of the code block (after “wp_reset_query()”)

      Let me know if that helps :)

  • aamirf

    Hi i have a page and i want to show some other pages inside it, how do i do that ……. ?

    • http://www.seobywebmechanix.com Arsham Mirshah

      Do you want to show the ENTIRE page .. or JUST the contents of the page.
      That is, you don’t want to use an iFrame, which will show the header and footer of the second page inside the first, correct? You rather just show the CONTENT (that which you enter into the “content” box of that page), correct?

  • ken

    it all makes sense now, thanks for the simplification

  • sxu888

    I have used the short code and post appeared on my static page as bullet point list. Is there any way I can have the posts showing as images without going through the story template process? for now? I have tried the story template but the site was broken.

    http://www.officialalana.com/

    • http://www.WebMechanix.com/ Arsham Mirshah

      Are you looking to use the post thumbnail instead of bullet points?

  • http://www.WebMechanix.com/ Arsham Mirshah

    This feature is now available through the add posts to pages plugin
    :
    http://wordpress.org/plugins/add-posts-to-pages/

  • ekta

    index.php file is blank under the theme folder…..then what to do???after that i tried plugin ….even though not working

    • http://www.WebMechanix.com/ Arsham Mirshah

      If the plugin isn’t working, it’s likely an issue with your theme :( Try changing to the default theme and trying again.

  • rockydude

    Hello, this code is only giving me the post title on the page but i would like to add a small summary of the post and then continue more link in the end. blow this i would like to have the dates the article posted on. how is this possible?

    • http://www.WebMechanix.com/ Arsham Mirshah

      Download the plugin and try that.
      It won’t have dates, but you can the excerpt and more link :) wordpress.org/plugins/add-posts-to-pages/

      • Johannes Kvamme

        Thanks! This fixed my problem. However, the posts is being displayed in their full length.

        This is what I’ve put into my page:
        [add_posts category=konfirmantnytt show=5 h=2 readmore="Les mer" img=false]

        Any understanding and help? Why are they in their full length?

        • http://www.WebMechanix.com/ Arsham Mirshah

          Johannes, I believe they are at their full length because you have not set the “read more” break point.

          Please refer to this page: http://en.support.wordpress.com/splitting-content/more-tag/ to set the read more break point.

          Hope this helps!

        • http://www.webmechanix.com/ Arsham Mirshah

          If you have a “read more” link then it assumes you want a full .. remove the “read more” and see what happens.

  • Helle Flindt-Rasmussen

    Hey Arsham, Thank you so much for this tutorial! I have been going out of my mind trying to figure out at way to do this – and there it was! Everything is working successfully, BUT I only see the headlines of the posts. I did everything right, but I can’t seem to figure out how to make it work so that – if not the whole post. then a good part of it – is showing.
    I am using a child theme of Twenty Fourteen

    Where to and how to make changes??!!
    I really hope you will help me, thank you so much!
    AND: do I need to put anything on the page, that shows the posts, fx [ add_posts category=nyheder tag=nyheder show=5 h=2 full=true readmore=false img=true] (without the extra space added ;-) )

  • Andreas Saarem

    Hi, I’ve been struggeling with the coding up here. I managed to do new custon template which is also shoving in templates dropdown, but I cant make it exactly same style as the rest of my pages. It’s totally blank and my page.php copy-paste gives error.

    Anyone knows what could go wrong when copying page.php to new template?

    • http://www.WebMechanix.com/ Arsham Mirshah

      Yes sir.. you want to change the name of the file (obviously). Then you want to make sure to name the template (at the top of the file with PHP comments):

      <?php
      /*
      Template Name: My Custom Page
      */

      Otherwise, try my plugin .. it might be easier: wordpress.org/plugins/add-posts-to-pages/

  • http://www.webmechanix.com/ Arsham Mirshah
  • awais

    helo i got to know about page.php(in theme->editor) but what is that page-stories.php(how to create it)

  • http://www.seobywebmechanix.com Arsham Mirshah

    page-stories.php is just an example to show the new page template that you need to create in order to add posts to a certain page in WordPress.