0

In my blog I want to put a label "Read More" and after clicking it, I want all my posts to appear but it's not working. Here is my code to try to be more specific:

add_filter('the_excerpt','openstrap_excerpt');
function openstrap_excerpt(){
    global $post;
    $link='<span class="readmore"><a href="'.get_permalink().'" > Continue reading &rarr;</a></span>';
    $excerpt=get_the_excerpt();     
    if ( preg_match('/<!--more(.*?)?-->/', $post->post_content) ) { 
        echo $excerpt.$link;
    } else {
        echo $excerpt;
    }
}
function openstrap_excerpt_read_more($text) {
   return '  <span><a href="'.get_permalink().'" class="readmore">Continue reading &rarr;</a></span>';

}
add_filter('excerpt_more', 'openstrap_excerpt_read_more');

function openstrap_custom_excerpt_length($length) {
    return 85;
}
add_filter('excerpt_length', 'openstrap_custom_excerpt_length');
  • why are you using this if ( preg_match('/<!--more(.*?)?-->/', $post->post_content) ) { – terminator Jul 14 '15 at 20:06
  • I wonder if you want to display the "Read more" link, regardless of the post length? Then this recent question is related. – birgire Jul 15 '15 at 8:58
0

i think this may solve your problem by removing this condition if ( preg_match('/<!--more(.*?)?-->/', $post->post_content) ) {

Not sure but give it a try

Adds Read More after the excerpt.

add_filter('the_excerpt','openstrap_excerpt');
function openstrap_excerpt(){
    global $post;
    $link='<span class="readmore"><a href="'.get_permalink().'" > read more &rarr;</a></span>';
    $excerpt=get_the_excerpt();   
    echo $excerpt.$link;

}

Following code Limit the length of the excerpt to 20 words

function openstrap_custom_excerpt_length($length) {
    return 85;
}
add_filter('excerpt_length', 'openstrap_custom_excerpt_length');

I don't why you are using the third function/filter and perhaps not required

  • dont happen nothing . please check [www.seoundsem.com/blog] – Rafael Nicolau Jul 16 '15 at 14:29
  • you want read more instead of continur reading ,, right? – terminator Jul 16 '15 at 14:31
  • just use the code i just edited . Don't use other two functions – terminator Jul 16 '15 at 14:48
  • i want to continue reading after first 20 words and only appear one time,now there are 2 times continue reading – Rafael Nicolau Jul 16 '15 at 14:57
  • and also i want that when i upload a post appear in colums or something....not all together – Rafael Nicolau Jul 16 '15 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.