#================================================
# function for limiting words
#================================================
if( !empty($_POST['newsletter'])) {
include("inc/edit/newsletter_upload.php");
}
global $post, $section, $subsection, $article, $is_events_home, $is_event, $section_index, $is_news, $newsletter,$thumbnail;
$path = explode('/',$_SERVER['REQUEST_URI']);
/*$section = $path[1];
$subsection = $path[2];*/
$article = $path[3];
if($path[1]=="events") { $is_events_home=true; }
if($path[1]=="event") { $is_event=true; }
if( $subsection=="" ) { $section_index=true; }
if( $path[1]=="events" || $path[1]=="event" || $path[1]=="donate" || $path[1]=="shop" ) { $section_index=false; }
$thumbnail = get_site_url() ."/wp-content/uploads/2018/05/thumbnail.jpg";
$event_time = "";
$description = "The Friends of St Peter’s works for the preservation, restoration and maintenance of the historic buildings and assets of the Parish Church of St Peter's Great Berkhamsted, Hertfordshire, England.";
if (have_posts()) {
while (have_posts()) {
the_post();
#get_template_part('top');
}
}
if ( get_field('carousel_image_1') ) { // check if the post has a Post Thumbnail assigned to it.
$thumbnail = (string) get_field('carousel_image_1');
#echo "T: ".$thumbnail;
}
ob_start();
the_content();
$description = ob_get_clean();
$description = strip_tags($description);
$description = addslashes($description);
$description = preg_replace( "/\r|\n/", "", $description );
$description = string_limit_words($description, 40);
if($section=="event"){
$thumbnail = "https://www.stpetersberkhamstedfriends.org.uk/images/working-party.jpg";
$event_time = " - ". tribe_get_start_date();
ob_start();
the_content();
$description = ob_get_clean();
$description = strip_tags($description);
$description = addslashes($description);
$description = preg_replace( "/\r|\n/", "", $description );
$description = string_limit_words($description, 30);
}
if($section=="news"){
ob_start();
the_content();
$description = ob_get_clean();
$description = strip_tags($description);
$description = addslashes($description);
$description = preg_replace( "/\r|\n/", "", $description );
$description = string_limit_words($description, 30);
#$description = "NEWS ".the_content();
if($description =="") {
$description ="Read latest local heritage news from the Friends of St Peter’s Berkhamsted";
}
}
wp_reset_query();
?>