Last active
February 8, 2017 12:46
-
-
Save SiGaCode/fe529a25138f5bfcaa6ca668eb365ea7 to your computer and use it in GitHub Desktop.
Check for the default <!--more--> and change it but leave custom <!--more Custom Text--> alone (c) Christina Arasmo: https://gist.github.com/carasmo/5e9781c3fd37fa9ef29d67f4c8157657
This file contains hidden or 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
| //*Custom Read More link. | |
| add_filter( 'excerpt_more', 'child_read_more_link' ); | |
| add_filter( 'get_the_content_more_link', 'child_read_more_link' ); | |
| add_filter( 'the_content_more_link', 'child_read_more_link' ); | |
| function child_read_more_link() { | |
| return ' ... <br><a class="more-link button blog" href="' . get_permalink() . '" rel="nofollow">Custom Read More</a>'; | |
| } |
This file contains hidden or 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
| <?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