Splitting nextgen gallery form the_content

Want to show the nextgen gallery somewhere else than the rest of the content?
Add this to your functions.php
// shows the content
echo ngg_content_split(“content”);
// shows the gallery
echo ngg_content_split(“gallery”)
function ngg_content_split($get=”content”){
//get the post content
$content_data = get_the_content();
//extract shortcode from content
preg_match(“/\[ngg([^}]*)\]/”, $content_data ,$matches);
$results = $matches[1];
//if shortcode exists in content
if (!empty($results) && $get==’gallery’){
$gallery_id = preg_replace(“/[^0-9]/”, ”, $matches[1]);
//make sure that NextGen is loaded
if (function_exists(nggShowGallery)){
//output gallery, showing only 4 images
return nggShowGallery( $gallery_id, null , 4 );
}
}elseif($get==’content’){
//extract gallery id from shortcode
$content = str_replace(“[ngg”.$results, “”, $content_data);
return ($content);
}else{
return “”;
}
}

Reply