1. Documentation
  2. Themes
  3. Storefront
  4. Codex
  5. Snippets

Display post excerpt instead of full content

Note: This is a Developer level doc. If you are unfamiliar with code and resolving potential conflicts, select a WooExpert or Developer for assistance. We are unable to provide support for customizations under our  Support Policy.

If you wish to automatically display the post excerpt on your archive / search results page etc (instead of using the <!– more –> tag), use:


add_action( 'init', 'jk_customise_storefront' );
function jk_customise_storefront() {
// Remove the storefromt post content function
remove_action( 'storefront_loop_post', 'storefront_post_content', 30 );
// Add our own custom function
add_action( 'storefront_loop_post', 'jk_custom_storefront_post_content', 30 );
}
function jk_custom_storefront_post_content() {
?>
<div class="entry-content" itemprop="articleBody">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'full', array( 'itemprop' => 'image' ) );
}
?>
<?php the_excerpt(); ?>
</div><!– .entry-content –>
<?php
}

view raw

functions.php

hosted with ❤ by GitHub

You can then adjust the excerpt display by filtering the_excerpt / excerpt_length, etc. as usual.

WooCommerce - the most customizable eCommerce platform for building your online business.

  • 30 day money back guarantee
  • Support teams across the world
  • Safe & Secure online payment