3: The Loop in Java

Drawer Code128 in Java 3: The Loop
3: The Loop
Code 128 Code Set A Recognizer In Java
Using Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications.
Figure 3-1: All these posts are output with the loop is images or paragraph breaks or YouTube videos, is stripped from this excerpt, so it should really be used with caution. Neither are there any parameters, which is a bit weird, really: you would think that you d be able to control the length of the actual excerpt, but there is no such setting. However, the_excerpt() does fulfill a purpose. You know that excerpt box on the Write Post screen in WordPress (Figure 3-2) If you put something there, the_excerpt() will output that instead of the first 55 words. So a simple Hi, this is my post! in the excerpt field for a post, and the usage of the_excerpt(), will result in a mere Hi, this is my post! output, despite it being a lot shorter than 55 words. What good is the_excerpt(), then It may be useful for lists where you don t want the blog posts to take up so much space, such as in search results or perhaps some kind of archive page.
Code 128 Code Set B Maker In Java
Using Barcode maker for Java Control to generate, create Code 128 Code Set C image in Java applications.
Part I: The WordPress Essentials
Code 128A Recognizer In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
Figure 3-2: The Excerpt box on the Write Post screen in WordPress admin
Generate Barcode In Java
Using Barcode maker for Java Control to generate, create bar code image in Java applications.
However, the most obvious usage would be as an alternative way of promoting a post. You can have a separate loop that would feature posts with a specific tag, and display their title as usual, but then just output the_excerpt() rather than the content. In fact, I ll show you how in just a little bit. For clarity s sake, this is the default usage of the_excerpt():
Scanning Barcode In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
< php the_excerpt(); >
Code 128B Maker In Visual C#.NET
Using Barcode creation for .NET Control to generate, create Code 128 Code Set B image in .NET applications.
Remember not to use the_excerpt() on templates displaying just one post, like single.php, for example. You need the_content() to display the full content! And, yes, should you want to you can use them together.
ANSI/AIM Code 128 Generator In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create Code 128C image in ASP.NET applications.
3: The Loop
Code128 Printer In .NET Framework
Using Barcode printer for .NET framework Control to generate, create Code 128 image in .NET applications.
TRY IT OUT List Excerpts Instead of Full Posts
Create Code 128C In Visual Basic .NET
Using Barcode drawer for Visual Studio .NET Control to generate, create Code 128 Code Set C image in Visual Studio .NET applications.
1. Open the default theme that ships with WordPress from wp-content/themes/default. The le you want
Make Bar Code In Java
Using Barcode generator for Java Control to generate, create barcode image in Java applications.
is index.php, and it contains the following code:
European Article Number 13 Generator In Java
Using Barcode maker for Java Control to generate, create GTIN - 13 image in Java applications.
< php /** * @package WordPress * @subpackage Default_Theme */ get_header(); > <div id="content" class="narrowcolumn" role="main"> < php if (have_posts()) : > < php while (have_posts()) : the_post(); > <div < php post_class() > id="post-< php the_ID(); >"> <h2><a href="< php the_permalink() >" rel="bookmark" title="Permanent Link to < php the_title_attribute(); >">< php the_title(); ></a></h2> <small>< php the_time('F jS, Y') > <!-- by < php the_author() > --></small> <div class="entry"> < php the_content('Read the rest of this entry »'); > </div> <p class="postmetadata">< php the_tags('Tags: ', ', ', '<br />'); > Posted in < php the_category(', ') > | < php edit_post_link('Edit', '', ' | '); > < php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ></p> </div> < php endwhile; > <div class="navigation"> <div class="alignleft">< php next_posts_link('« Older Entries') ></div> <div class="alignright">< php previous_posts_link('Newer Entries »') ></div> </div> < php else : > <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> < php get_search_form(); > < php endif; >
Paint Bar Code In Java
Using Barcode creator for Java Control to generate, create barcode image in Java applications.
Part I: The WordPress Essentials
Planet Encoder In Java
Using Barcode generation for Java Control to generate, create USPS Confirm Service Barcode image in Java applications.
</div> < php get_sidebar(); > < php get_footer(); >
Reading EAN-13 Supplement 5 In Visual Studio .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in VS .NET applications.
2. You want to change the_content to the_excerpt so that only excerpts are displayed. You ll nd the following code snippet around line 20 in the le:
Data Matrix 2d Barcode Printer In Visual C#.NET
Using Barcode drawer for .NET Control to generate, create DataMatrix image in Visual Studio .NET applications.
< php the_content('Read the rest of this entry »'); >
EAN-13 Supplement 5 Maker In VS .NET
Using Barcode creator for VS .NET Control to generate, create EAN13 image in .NET applications.
3. Replace the code from step 2 with the following, so that the theme will output the excerpt rather than
Data Matrix 2d Barcode Drawer In Visual Studio .NET
Using Barcode maker for ASP.NET Control to generate, create Data Matrix 2d barcode image in ASP.NET applications.
the full content:
Draw EAN / UCC - 14 In .NET
Using Barcode printer for ASP.NET Control to generate, create EAN / UCC - 13 image in ASP.NET applications.
< php the_excerpt(); >
Code 39 Maker In Visual Studio .NET
Using Barcode encoder for VS .NET Control to generate, create ANSI/AIM Code 39 image in .NET framework applications.
4. Save and upload index.php. Now you ll see the default excerpt (the rst 55 characters from the
Draw EAN13 In .NET
Using Barcode creator for ASP.NET Control to generate, create European Article Number 13 image in ASP.NET applications.
post) rather than the full post view when visiting the site. Since the theme has its own single.php template, you don t have to worry about just showing excerpts when you read individual posts (see Figure 3-3).
Figure 3-3: Two posts showing the excerpt rather than the full post; note the ellipsis ([. . .]) at the end of them
5. If you want to, you can ll out a custom excerpt in the appointed box found on the Write Post screen in
WordPress admin (Figure 3-4). If you do, the excerpt will display instead (Figure 3-5).
3: The Loop
39 Figure 3-4: Editing one of the posts in WordPress admin, adding an excerpt in the appointed box
Figure 3-5: The edited post now displays the custom excerpt rather than the automatic one
About Those Sticky Posts
WordPress added something called sticky posts back in version 2.7. People familiar with online discussion forums will recognize the lingo; it is basically something that sticks to the top at all times (see Figure 3-6). The idea is that, in the Edit Post screen, you set a blog post to sticky, hence making it stay on top at all times. If two posts are sticky, you ll end up with both on top, in chronological