WordPress.org

Ready to get started?Download WordPress

Forums

Using the loop (I am confused) (3 posts)

  1. Jones Elizabeth
    Member
    Posted 2 years ago #

    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) ?

  2. Steven Jones
    Member
    Posted 2 years ago #

    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.

  3. Mathias Gomig
    Member
    Posted 2 years ago #

    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;

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags