php - Multiple "More" links for the_excerpt(); in Wordpress -
i've changed excerpt link in wordpress "[...]" "read more" code below. want know if there way use more 1 link excerpt. let's posts in 1 category have "read more" excerpt, , posts in category have "see photos" excerpt link. possible?
remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'custom_trim_excerpt'); function custom_trim_excerpt($text) { // fakes excerpt if needed global $post; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_length = 24; $words = explode(' ', $text, $excerpt_length + 1); if (count($words) > $excerpt_length) { array_pop($words); array_push($words, '...<br /><a href="'.get_permalink().'" class="tag">read more</a>'); $text = implode(' ', $words); } } return $text; }
yes can it. use excerpt_more filter change "[...]" , in_category function check category read more text.
try code.
function custom_excerpt_more( $more ) { $read_more_txt = 'read more..'; if (in_category('cat_slug')) $read_more_txt = 'see photos..'; else if (in_category('cat_slug2')) $read_more_txt = 'something else..'; return ' <a title="'. $read_more_txt .'" href="'. get_permalink( get_the_id() ) .'">'. $read_more_txt .'</a>'; } add_filter( 'excerpt_more', 'custom_excerpt_more' );
Comments
Post a Comment