Tag Archives: excerpt

excerpt – read more link and number of character to display


/* Set size of characher in excerpt */
function legal_excerpt_length($length) {
// return 35;
$legal_options = get_option( 'legal_theme_options' );
global $post;
if ($post->post_type == 'post')
if(!empty($legal_options['excerptlength'])) {
return __($legal_options['excerptlength']);
} else {
return __('50','legal');
}
}
add_filter('excerpt_length', 'legal_excerpt_length');


/* readmore button if more content */
function legalt_excerpt_more() {
global $post;
if ($post->post_type == 'post') {
return '...<div class="button-div"><a href="' . get_permalink() . '" class="button-read">' . __('Read more', 'legal') . '</a></div>';
}
}
add_filter("excerpt_more", "legalt_excerpt_more");

Advertisements

Change Excerpt length and Readmore link for custom post type

functions.php

// Excerpt length for different posts type

function new_excerpt_length($length) {
global $post;
if ($post->post_type == ‘post’)
return 12;
else if ($post->post_type == ‘caseresult’)
return 7;
else
return 55;
}
add_filter(‘excerpt_length’, ‘new_excerpt_length’);

// Replaces the excerpt “Read more” text
function new_excerpt_more($more) {
global $post;
if ($post->post_type == ‘post’)
return ‘<a class=”moretag” href=”‘. get_permalink($post->ID) . ‘”> Read post</a>’;
else if ($post->post_type == ‘caseresult’)
return ‘<a class=”moretag” href=”‘. get_permalink($post->ID) . ‘”> Read caseresult</a>’;
else
return ‘<a class=”moretag” href=”‘. get_permalink($post->ID) . ‘”> Read More…</a>’;
}
add_filter(‘excerpt_more’, ‘new_excerpt_more’);

%d bloggers like this: