Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==============================================
- *To Displays the post excerpt
- ===============================================*/
- <?php the_excerpt(); ?>
- /*===================================================================================
- *Use with Conditional Tags
- *Replaces the_content() tag with the_excerpt() when on archive or category pages.
- =====================================================================================*/
- <?php
- if ( is_category() || is_archive() ) {
- the_excerpt();
- } else {
- the_content();
- }
- ?>
- /*======================================================================================
- *Control Excerpt Length using Filters
- *By default, excerpt length is set to 55 words.
- *To change excerpt length to 20 words using excerpt_length filter,
- add the following code to functions.php file in your theme:
- =======================================================================================*/
- <?php
- function custom_excerpt_length( $length ) {
- return 20;
- }
- add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
- ?>
- /*======================================================================================
- *Make the "read more" link to the post
- *Place this in a theme's functions.php to make the "read more" link to the post
- =======================================================================================*/
- <?php
- function new_excerpt_more( $more ) {
- return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">Read More</a>';
- }
- add_filter( 'excerpt_more', 'new_excerpt_more' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement