Using Manual Excerpts in WordPress Pages

By Page Wood September 18, 2012

WordPress is an awesome CMS out of the box, but I typically end up building my own custom post types and loops for usability, and SEO purposes. After all, a CMS is meant to make adding and organizing content on a website and easy task.

One of the projects I’m working on is the redesign of F.S. Welsford Company’s website. They’re a Valve business out of Pennsylvania. The nature of their business might sound simple, but it’s far from simple. Valves come in all shapes, sizes, types, etc. etc. etc.. One of the things that their site needed is a custom template to display their Product Line like so:

WordPress Custom Template

To make this happen, I built a custom Post Type for “Product Line.” This easily allows them to add a new Company in the WordPress backend. They needed the ability to display each Company on the Products page with a short description, but also needed customers to have the ability to navigate to a page with more detail. So how do we do this in an automated fashion without adding multiple pages (i.e. a page with the basic product info, then a page with all of the detail)? Manual excerpts!

For each Product Line item, they specify the company image by using the “Featured Image” box on the Add Post page. Then, they type in the generic company description to be used on the “Product Line” page. After this, a manual excerpt is added by clicking the “Insert More Tag” icon in the WordPress post editor. Any content that’s added below the more tag will not be displayed on the Product Line page. See an example of this in action with the WordPress editor:

 

WordPress More Tag for Manual Excerpts

 

Now, we need to put this to work…. The WordPress system allows the “More tag” for the home page, but does not have this functionality built into regular pages. We need to add this capability to our loop manually. You can try to just use the_excerpt() tag, but it’s not going to keep unordered lists from showing up on the “Product Line” page.

To allow the manual excerpt on our Product line page, I added the following to the loop:

 

<?php
global $more;
$more = 0;
?>

 

This enables the use of manual excerpts. Now, we need to control how to display the manual excerpt and so we use the code below within the loop:

<?php the_content(''); ?>

 

The (”) in the call for the_content specifies that at the end of the excerpt, nothing needs to follow. Typically on blog posts you would see a ‘Read More’ at the end of the post, but that’s not needed for our purposes here.

Now, when users check out the Product Line page they see only the short description of the Company, and when they click the Company name or logo, they’re taken to a page with the full content of the Product Line Post:

WordPress Custom Post Type with Manual ExcerptThere you have it, manual excerpts on interior pages with WordPress.

 

 

Leave a Comment