How to make excerpt say ‘More…’
-
On one of my sites I got the excerpt working perfectly however the theme on another site I’m working on is really drilling me!
On the site that works I put this into the functions
<?php function excerpt_ellipse($text) { return str_replace('[...]', ' <a href="'.get_permalink().'">More ?</a>', $text); } add_filter('the_excerpt', 'excerpt_ellipse'); ?>
and it works fine but on this site the functions is a little messed up because I’m not using a custom theme but a theme I just downloaded and this is whats in the functions..
<?php if ( function_exists('register_sidebar') ) { register_sidebar(array('name' => 'Sidebar Top','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); register_sidebar(array('name' => 'Sidebar Left','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); register_sidebar(array('name' => 'Sidebar Right','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); register_sidebar(array('name' => 'Sidebar Bottom','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); register_sidebar(array('name' => 'Footer Left','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); register_sidebar(array('name' => 'Footer Center','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); register_sidebar(array('name' => 'Footer Right','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); } remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'custom_trim_excerpt'); remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'custom_trim_excerpt'); function custom_trim_excerpt($text) { // Fakes an excerpt if needed global $post; if ( '' == $text ) { $text = get_the_content(''); $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_length = apply_filters('excerpt_length', 90); $words = explode(' ', $text, $excerpt_length + 1); if (count($words) > $excerpt_length) { array_pop($words); array_push($words, '...'); $text = implode(' ', $words); } } return $text; } ?>
I realize that here
array_push($words, '...');
is where the more part is however how can I make it like the other site where it does not only display dots or words but it also links into the post.Thank you in advance!
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘How to make excerpt say ‘More…’’ is closed to new replies.