Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • The Loop in Wordpress

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 280
    Comment on it

    The Loop

    The Loop is PHP code used by WordPress to display posts. Using The Loop in WordPress we can display each post in the current page.

    In wordpress have_posts() simply calls into $wp_query->have_posts() checks, if there are any posts exists or not.
    And the_posts() simply calls $wp_query->the_posts(), which advances the loop counter and sets up the global $post variable as well as all of the global post data. Once we have exhausted the loop, have_posts() will return false and we are done.


    <?php while ( have_posts() ) : the_post(); ?>    
            <a href="<?php the_permalink(); ?>">
                <?php the_title(); // title of the post. ?> 
            <?php the_time('F jS, Y'); // time of the post ?>
            <?php the_excerpt(); // display unique content. ?>
        <div class="entry">
            <?php the_content(); // whole content of the post. ?>
    <?php endwhile; ?>

    Simple Example:-

    Visit my next blog The Loop in WordPress -Part 2 to know about the_title(), the_time() the_content() the_excerpt() Loop in WordPress.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: