-
Book Overview & Buying
-
Table Of Contents
WordPress 2.7 Cookbook
What is the WordPress loop? The loop is a group of PHP instructions that allows you to retrieve your posts from the database. In this recipe, you'll learn how to use the WordPress loop efficiently.
The WordPress loop is basically a simple PHP loop that fetches posts from the database and displays it on the page. It can be placed anywhere on your theme files. All available themes use it to retrieve the posts, for example on index.php, single.php, or page.php.
Paste the following code where you'd like to display the list of posts. Most of the time, the loop is used on the index.php, category.php, search.php files, but you can use it wherever you want, for example, on a page using a custom page template.
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<?php the_title();?>
<?php the_content();?>
<?php endwhile;
endif; ?>
This basic piece of code first checks...
Change the font size
Change margin width
Change background colour