Created
August 23, 2020 05:25
-
-
Save TheBinitGhimire/1db2ee80b8cd2d9ffbffebd6268571ab to your computer and use it in GitHub Desktop.
Static Excerpts for WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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