Skip to content

Instantly share code, notes, and snippets.

@carasmo
Last active August 2, 2016 19:32
Show Gist options
  • Save carasmo/5e9781c3fd37fa9ef29d67f4c8157657 to your computer and use it in GitHub Desktop.
Save carasmo/5e9781c3fd37fa9ef29d67f4c8157657 to your computer and use it in GitHub Desktop.
Check for the default <!--more--> and change it but leave custom <!--more Custom Text--> alone
<?php
// don't use
/** ======================================================================================
*
* Read More the_content_more_link
* Check for the default <!--more--> and change it
* but leave custom <!--more Custom Text--> alone
*
======================================================================================= */
function yourprefix_more_content_more_link( $more_link ) {
global $post;
if( strstr( $post-> post_content,'<!--more-->') ) {
return sprintf( '<a href="%s" class="more-link">%s</a>', get_permalink(), 'Read More' );
} else {
return $more_link;
}
}
add_filter( 'the_content_more_link', 'yourprefix_more_content_more_link' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment