Skip to content

Instantly share code, notes, and snippets.

@gnuget
Created February 22, 2010 06:41
Show Gist options
  • Save gnuget/310869 to your computer and use it in GitHub Desktop.
Save gnuget/310869 to your computer and use it in GitHub Desktop.
<?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