Skip to content

Instantly share code, notes, and snippets.

@Rhymes2k
Created October 18, 2015 16:35
Show Gist options
  • Save Rhymes2k/9ebd7b2877b826241a3b to your computer and use it in GitHub Desktop.
Save Rhymes2k/9ebd7b2877b826241a3b to your computer and use it in GitHub Desktop.
Custom More Text With WordPress In Functions.php
function custom_more($more_link, $more_link_text) {
return str_replace($more_link_text, 'Keep reading this post', $more_link);
}
add_filter('the_content_more_link', 'my_more_link', 10, 2);
////////////////////////////////////////////////////////////////////////////////
Showing Posts With Custom Excerpt Length And Custom Read More Text In WordPress
<?php
//showing welcome post (post id =1)
// retrieve one post with an ID of 5
query_posts( 'p=1' );
function new_excerpt_length($length) {
return 28;
}
add_filter('excerpt_length', 'new_excerpt_length');
function new_excerpt_more($more) {
global $post;
return '<a href="'. get_permalink($post->ID) . '"> <br />read more....</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
// set $more to 0 in order to only get the first part of the post
global $more;
$more = 0;
// the Loop
while (have_posts()) : the_post();
the_excerpt();
endwhile;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment