trim auto and manually excerpts

Displaying the manual and auto excerpt the same way with [...] at the
end and Bootstrap .btn-default „read more“ link below
This commit is contained in:
Holger Koenemann 2014-12-22 08:57:31 +01:00
parent 38f89401b9
commit ec81dcebed
3 changed files with 21 additions and 11 deletions

View File

@ -21,14 +21,11 @@
<?php echo get_the_post_thumbnail( $post_id, 'large' ); ?>
<div class="entry-content">
<?php
/* translators: %s: Name of current post */
the_excerpt( sprintf(
__( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'understrap' ),
the_title( '<span class="screen-reader-text">"', '"</span>', false )
) );
?>
<?php
/* translators: %s: Name of current post */
the_excerpt( );
?>
<?php
wp_link_pages( array(

View File

@ -85,10 +85,21 @@ add_filter('show_admin_bar', '__return_false');
/**
/* Adding the Read more link to excerpts
*/
function new_excerpt_more( $more ) {
/*function new_excerpt_more( $more ) {
return ' <p><a class="read-more btn btn-default" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'understrap') . '</a></p>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
add_filter( 'excerpt_more', 'new_excerpt_more' );*/
/* Removes the ... from the excerpt read more link */
function custom_excerpt_more( $more ) {
return '';
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );
/* Add support for Featured Images per Post */
/* Adds a custom read more link to all excerpts, manually or automatically generated */
add_theme_support( 'post-thumbnails' );
function all_excerpts_get_more_link($post_excerpt) {
return $post_excerpt . ' [...]<p><a class="btn btn-default" href="'. get_permalink($post->ID) . '">' . 'Read More...' . '</a></p>';
}
add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');

View File

@ -28,6 +28,7 @@ get_header(); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
@ -35,6 +36,7 @@ get_header(); ?>
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
<?php understrap_paging_nav(); ?>