WordPress.org

Support

Support » How-To and Troubleshooting » Using the loop (I am confused)

Using the loop (I am confused)

  • I have just started to learn about wordpress, & am currently trying to understand the loop.

    Do I need to have a separate loop for the index.php page, & another for say single.php ( for displaying single posts) ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You should have separate templates to control the presentation of the index.php (typically the home page) and (single.php) the single post.

    The loop controls what data should be outputted on the screen. So for the index it will typically show the latest posts (usually 10) and with the single.php it will just show details for that specific post.

    The best way to learn this is read the codex and install and customise a simple starter theme such as Bones (http://themble.com/bones/)

    Good luck.

    Just try the same code in index.php and in single.php.
    You will see the difference.


    if (have_posts()) :
    while (have_posts()) :
    the_post();
    the_title();
    the_content();
    endwhile;
    endif;

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using the loop (I am confused)’ is closed to new replies.
Skip to toolbar