Created
February 22, 2010 06:41
-
-
Save gnuget/310869 to your computer and use it in GitHub Desktop.
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 | |
function multiline_with_more($multiline_name){ | |
global $post; | |
///Get the content of the multiline custom field | |
$multiline = get('multiline'); | |
//if the page is_Single we replace the <!--more--> tag for: | |
//<span id="more-9-{$custom_Field_name"></span> | |
if(is_single($post->ID)){ | |
preg_match('/(.*)(\<\!\-\-more\-\-\>)(.*)/is',$multiline,$matches); | |
return $matches[1]."<span id='more-{$post->ID}-{$multiline_name}'></span>".$matches[3]; | |
}else{ | |
//if not is_single the page we put a link with the message "Read the rest of this entry »" | |
//and remove all the content after to <!--more--> | |
$permalink = get_permalink( $post->ID ); | |
preg_match('/(.*)(\<\!\-\-more\-\-\>)(.*)/is',$multiline,$matches); | |
return $matches[1]."<a href='{$permalink}#more-{$post->ID}-{$multiline_name}'>Read the rest of this entry</a>"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment