Skip to content

Instantly share code, notes, and snippets.

@TheBinitGhimire
Created August 23, 2020 05:25
Show Gist options
  • Save TheBinitGhimire/1db2ee80b8cd2d9ffbffebd6268571ab to your computer and use it in GitHub Desktop.
Save TheBinitGhimire/1db2ee80b8cd2d9ffbffebd6268571ab to your computer and use it in GitHub Desktop.
Static Excerpts for WordPress
<?php
/**
*
*** Static Excerpts for WordPress
*** Author: Binit Ghimire
*** Author URL: https://WHOISbinit.me/
*** How to use?
* 1. Insert this piece of code at the end of your Theme Functions file (i.e. functions.php)!
* 2. Replace the content written inside double quotes (" and ") in Line 17 with the static excerpt content that you'd like to use!
***
*
*** Make sure to give proper credits to the author while sharing this code with others!
*
**/
function static_excerpt_wordpress( $excerpt ) {
if ( is_admin() ) {
return $excerpt;
}
$excerpt = "Hello, there! This is my static excerpt.";
$excerpt .= '<p class="your-read-more-area-class"><a title="'.get_the_title().'" class="your-read-more-button-class" href="'.get_the_permalink().'">Read More<span class="screen-reader-text">'.get_the_title().'</span></a></p>';
return $excerpt;
}
add_filter( 'get_the_excerpt', 'static_excerpt_wordpress', 0 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment