GoodLayers Event – Add an excerpt in the event post

The docs for developer mean you must have knowledge and coding skill. Although, we’re create the docs for developer to help you achieve something not available in original feature, but we don’t provide support for anything not work when you reference with docs for developer. If the example code not work for you, please debug it by your-self or hire a freelancer to debug it for you instead.

All the customize will lose when you update our theme/plugin to new version in future. To avoid it, you must use filter and action: https://developer.wordpress.org/plugins/hooks/.

In the Confera theme, we have a few styles for the even/conference style like:

– List style: https://demo.goodlayers.com/u/confera/online/schedule-list-1/

– Grid style: https://demo.goodlayers.com/u/confera/online/schedule-card-style/

In those styles, we don’t support the excerpt, that’s why we’re creating this article to help you add the excerpt by yourself.

Step 1:

  • Backup your website.
  • Create a folder call: goodlayers-event in the child theme.
  • Copy those files into the goodlayers-event folder: event-item.php, event-style.php and pb-elelement-event.php.

Step 2:

Call the file from child theme to override the original file from the goodlayers event plugin. Please add this function in the functions.php file of the child theme:

// Call the customize file in the child theme
require_once get_stylesheet_directory() . '/goodlayers-event/event-style.php';
require_once get_stylesheet_directory() . '/goodlayers-event/event-item.php';
require_once get_stylesheet_directory() . '/goodlayers-event/pb-element-event.php';

Override the original file after setup theme:

// Override the original file after setup theme
add_action('after_setup_theme', 'gdlr_core_event_add_pb_element_custom');
if(!function_exists('gdlr_core_event_add_pb_element_custom')){
	function gdlr_core_event_add_pb_element_custom(){
		if(class_exists('gdlr_core_page_builder_element')){
			gdlr_core_page_builder_element::add_element('event-g', 'gdlr_core_pb_element_event_g_custom');
		}
	}
}

Step 3:

Go to event-style.php:

Original Code:

	if( !class_exists('gdlr_core_event_g_style') ){
		class gdlr_core_event_g_style{

Change it to:

if( !class_exists('gdlr_core_event_g_style_custom') ){
		class gdlr_core_event_g_style_custom{

Search event style 1 and add the excerpt.

Original Code:

$ret .= '<div class="gdlr-core-content-wrap" >';
$ret .= $this->get_title($args);
$ret .= $this->get_info($infos);
$ret .= '</div>';

Change it to:

$ret .= '<div class="gdlr-core-content-wrap" >';
$ret .= $this->get_title($args);
$ret .= $this->get_info($infos);					
if( !empty($args['excerpt-number']) ){
    $ret .= $this->get_excerpt($args['excerpt-number']);
}
$ret .= '</div>';

Go to event-item.php

Original Code:

// Around line 6-7	
if( !class_exists('gdlr_core_event_g_item') ){
		class gdlr_core_event_g_item{

// Around line 363
$query = $this->query;
$event_style = new gdlr_core_event_g_style();

// Around line 397
$event_style = new gdlr_core_event_g_style();

// Around line 499
add_action('wp_ajax_gdlr_core_event_g_ajax', 'gdlr_core_event_g_ajax');
add_action('wp_ajax_nopriv_gdlr_core_event_g_ajax', 'gdlr_core_event_g_ajax');
if( !function_exists('gdlr_core_event_g_ajax') ){
    function gdlr_core_event_g_ajax(){

Change it to:

// Around line 6-7	
if( !class_exists('gdlr_core_event_g_item_custom') ){
		class gdlr_core_event_g_item_custom{

// Around line 363
$query = $this->query;
$event_style = new gdlr_core_event_g_style_custom();
$event_style->get_content($this->settings);

// Around line 397
$event_style = new gdlr_core_event_g_style_custom();
$event_style->get_content($this->settings);

// Around line 499
add_action('wp_ajax_gdlr_core_event_g_ajax', 'gdlr_core_event_g_custom_ajax',9);
add_action('wp_ajax_nopriv_gdlr_core_event_g_ajax', 'gdlr_core_event_g_custom_ajax',9);
if( !function_exists('gdlr_core_event_g_custom_ajax') ){
    function gdlr_core_event_g_custom_ajax(){

Go to pb-element-event.php

Original Code:

// Around line 6
add_action('plugins_loaded', 'gdlr_core_event_add_pb_element');
	if( !function_exists('gdlr_core_event_add_pb_element') ){
		function gdlr_core_event_add_pb_element(){

			if( class_exists('gdlr_core_page_builder_element') ){
				gdlr_core_page_builder_element::add_element('event-g', 'gdlr_core_pb_element_event_g'); 
			}
			
		}
	}
	
	if( !class_exists('gdlr_core_pb_element_event_g') ){
		class gdlr_core_pb_element_event_g{

// Around line 121
'condition' => array( 'event-style' => 'style-2' )

// Around line 339
'event-style' => 'style-1', 'event-info' => array('date', 'time', 'location'),

// Around line 449
$event_item = new gdlr_core_event_g_item($settings);

Change it to:

// Around line 6
if( !class_exists('gdlr_core_pb_element_event_g_custom') ){
		class gdlr_core_pb_element_event_g_custom{

// Around line 121
'condition' => array('event-style' => array('style-1', 'style-2', 'style-1-room', 'style-card', 'style-multi-date', 'style-grid'))

// Around line 339
'event-style' => 'style-1', 'event-info' => array('date', 'time', 'location', 'caption'),

// Around line 449
$event_item = new gdlr_core_event_g_item_custom($settings);

Please clear the cache/cookie on your website before check it again.