• Whenever I include the loop in one of my custom template pages, it fails. When I copy that exact same code (minus the template name code) and paste it into one of WP’s standard pages (index.php, e.g.), it works fine and displays all posts.

    Is there a basic concept I’m not grasping here? Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Could you be more clear about what exactly you’re doing when you try to include the loop?

    Let’s say your custom template have an index.php

    What are you trying to include there ?

    Juste paste the loop code you’re trying to use.

    Also, how exactly it fails? It shows no posts? You have an error message?

    S.

    Thread Starter gatorbake

    (@gatorbake)

    Thank for the reply SimonJ. When I started describing to you exactly how it failed, I realized what was happening.

    The basic concept I wasn’t grasping is that apparently some of the predefined templates (like index.php) by default only grab “posts” via the loop.

    But when you create a custom template, you have to tell the loop to grab only posts. My page was grabbing other entries that were not posts and they showed up blank. To fix this I added the following line before my loop and it did the trick:

    query_posts("post_type=post");

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘using the loop in custom templates’ is closed to new replies.