@Poremsky.com

Tips & Tricks for Windows, Office, and Whatever

  • Home
  • Windows
  • Office
  • Web Design
  • WordPress
  • Internet Explorer

Part 3: Custom Excerpts

Published on September 15, 2011 Last reviewed on May 3, 2017

While I was working on the index, I decided I wanted to include a short excerpt instead of just making a list of hyperlinks.

We're using a custom excerpt that was too long and while the RSS excerpt worked ok, I wanted shorter and control over the "more" indicator. I could have solved this problem by adding short excerpts to every page, but that would take forever. 🙂

With a little more searching, I found instructions for creating filters and custom excerpt functions (added to the functions.php file).

This line goes into your template file:

<?php my_excerpt('excerptlength_index', 'excerptmore'); ?>

The function goes into your functions.php

function excerptlength_teaser($length) {    return 45;}
function excerptlength_index($length) {    return 29;}
function excerptmore($more) {    return '...';}

function my_excerpt($length_callback='', $more_callback='') {    
global $post;    
if(function_exists($length_callback)){
add_filter('excerpt_length', $length_callback);    
}    
if(function_exists($more_callback)){        
add_filter('excerpt_more', $more_callback);    }    
$output = get_the_excerpt();    
$output = apply_filters('wptexturize', $output);    
$output = apply_filters('convert_chars', $output);    
$output = '<p>'.$output.'</p>';    echo $output;}
?>

Subscribe
Notify of
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Recent Posts

  • How to Remove Office Licenses from Windows
  • Use a JavaScript bookmarklet to open an archive for a webpage
  • How to fix records that are all in one column
  • Change Password or Pin Complexity after removing from Intune
  • Server drafts location is not valid error message

Recent Comments

  • Hornblower409 on How to Remove Office Licenses from Windows
  • FUAD on Remove Office Licenses from Windows
  • Brian DuBridge on Add the Recent Items Folder to Windows 10 Quick Access
  • Renee Moodie on Remove Office Licenses from Windows
  • John P on Remove Office Licenses from Windows

© 2026 · @Poremsky.com

wpDiscuz
Go to mobile version