Support » Themes and Templates » Displaying “the loop” within a Page

  • Hello,

    I am attempting to use “The loop” functionality to display posts on a dynamic Page in wordpress.
    I am using WordPress 1.5 and have read the codex thoroughly as well as many topics here on the support forum but have been unsuccessful in implementing what I have in mind.

    In my attempts, I have utilized the example template on the codex in creating a page which uses the loop. The page displayed only the title of the page I had just created instead of the expected posts.

    My wordpress setup is as follows:
    – WordPress 1.5 installation, root directory
    – using home.php as main home page (no posts)
    – wish to create ‘blog’ page using a ‘loop’ template to display posts
    – using permalinks structure /blog/%year%/%monthnum%/%day%/%postname%/

    Any thoughts on this issue or suggestions on an alternate setup would be greatly appreciated.

    Thank you,

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator James Huff


    Actually, you’re lucky that you got any PHP to render in the first place. You’ll have better luck if you activate one of these plugins:


    More info:

    Hi macmanx,

    Thanks for your reply.

    That plugin will run php code inserted into a Page is that correct?
    Now as I understand, the template file will execute the php code. The Page (which is generated from that template) doesn’t have any code in it, in fact, it is completely blank. All the display elements should be pulled from the template file itself.
    The issue is, the code in the template file used to display is infamous ‘Loop’ isn’t working as it should, despite what the wordpress codex is telling me. I am wondering why that is. Or have I missed something fundamental about ‘Pages’ in WordPress 1.5 ?

    Note that a standard use of The Loop on a Page template runs much like it would on a single.php template: it only outputs the contents of that individual Page. To get more out of it you’re going to need to implement the query_posts() function to call up the posts you want to display. For example, just before The Loop occurs on a template I’ve set up for my “archives” Page, I have this:

    <?php query_posts("orderby=post_date&order=DESC&showposts=20"); ?>

    This displays the last 20 posts, ordered by post date (in descending order).

    Thank you Kafkaesqui,

    That clears up a lot. So the page itself was being treated as a post. That is why only the page name was being displayed. In order to display other posts the database has to be queried.

    That solution worked for me perfectly. I very much appreciate both of your help.

    Thank you,

    Moderator James Huff


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Displaying “the loop” within a Page’ is closed to new replies.