Last active
April 23, 2016 15:09
-
-
Save MatRouault/b6e64939d76d9a00e53250d5482bb4b5 to your computer and use it in GitHub Desktop.
Beans - Show Excerpt or Troncate Content if we're NOT on a singular post/page
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 | |
// Do not include the opening php tag if it is already included in your file. | |
//* Show Excerpt or Troncate Posts Content | |
add_filter( 'the_content', 'sps_troncate_post_content' ); | |
function sps_troncate_post_content( $content ){ | |
if ( !is_singular() ) | |
if ( has_excerpt() ) { | |
return '<p>' . get_the_excerpt() . '</p><p>' . beans_post_more_link() . '</p>'; | |
} | |
else { | |
return '<p>' . wp_trim_words( wp_strip_all_tags( $content, true ), 40, '...' ) . '</p><p>' . beans_post_more_link() . '</p>'; | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment