Created
October 18, 2015 16:35
-
-
Save Rhymes2k/9ebd7b2877b826241a3b to your computer and use it in GitHub Desktop.
Custom More Text With WordPress In Functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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