Skip to content

Instantly share code, notes, and snippets.

@Asok17
Last active February 20, 2019 10:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Asok17/6533a2544463887a41ebb040c40a817c to your computer and use it in GitHub Desktop.
Save Asok17/6533a2544463887a41ebb040c40a817c to your computer and use it in GitHub Desktop.
StyleBlog Plus - Read More
/**
* Filter to alter excerpt more text
*/
if( !function_exists( 'styleblog_plus_excerpt_more' ) ) :
/*
* Excerpt More
*/
function styleblog_plus_excerpt_more( $more ) {
if( is_admin() ) {
return $more;
}
if( is_home() || is_archive() ) {
return sprintf( '<a href="%1$s" class="more-link">&nbsp;%2$s</a>', esc_url( get_permalink( get_the_ID() ) ), esc_html__( 'Read More...', 'styleblog-plus' ) );
} else {
return '';
}
}
endif;
add_filter( 'excerpt_more', 'styleblog_plus_excerpt_more' );
@Asok17
Copy link
Author

Asok17 commented Feb 18, 2019

If you want space before the Read More text, you can add &nbsp; before %2$s.

@Joso
Copy link

Joso commented Feb 18, 2019

hi, I tried the code, but not show the "read more".

@Asok17
Copy link
Author

Asok17 commented Feb 19, 2019

hi, I tried the code, but not show the "read more".
Hi Joso, It is working for me. Could you replace the whole function code with the above code.

@Joso
Copy link

Joso commented Feb 19, 2019

Hi Asok17, I update your code, and I'm sorry but it not work on my site...; I ask: need to add strings of codes in other files? for example to show the category and the author I had to add a string in other files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment