• I’m loving your plugin and I’ve been doing some tweaking of it for my client’s needs. I added some custom fields to the Events pages and got those working. I am able to display a list of events on our homepage and it’s formatted so it looks very nice. You can see the list under “Upcoming IPA Events” on this page: Go to page (we’re still in testing and building phase).

    With my custom fields I was able to add two fields, one is “display on homepage” and the other is “put on top of the list”. Both or true/false fields and I’m able to capture the fields and use the data. I’ve made some changes to your gg-shortcodes.php code to do what I need to do. BUT here’s my issue, I don’t know how to take an event that I’ve designated to be “top of the list” and actually have it render at the top of the list. Can you point me in the right direction, I’m by no means a PHP expert, I know enough to be dangerous. Basically I need some sort of “if statement” that says:

    if($topoflist == 1)
    { move this event to the top of the list }

    Any ideas, pointers, code or encouragement would be SO appreciated! I’m pretty happy with 90% of what I’ve done in your PHP code, but this last bit has me stumped.

    Thanks for any help you can provide.

    Here is the code for my gg_shortcodes.php file:

    <?php
    
    function gg_eventlist_shortcode( $atts, $content = null ){
     extract( shortcode_atts( array(
          'orderby' => 'meta_value_num',
    	  'order' => 'ASC',
    	  'limit' => -1,
    	  'category' => 'all',
    	  'all_dates' => false,
    	  'format' => 'content'
          // ...etc
          ), $atts ) );
    
    $return = apply_filters('gg_shortcode_begin', '<div class="event-listing gg_short">');
    
    	global $post;
    	$gg_event_options = get_option( 'gg_event_options');//get event plugin options
    		$clickedDate = $_GET['date'];
    		$cat = $_GET['cat'];
    
    		if($clickedDate){
    			$meta_query =  array(
    				array(
    					'key' => 'gg_event_dates',
    					'value' => date($gg_event_options['gg_event_date_format'], strtotime($clickedDate)),
    					'compare' => 'LIKE'
    				)
    			);
    
    			$args = array(
    				'post_type' => 'gg_events',
    				'posts_per_page' => -1,
    				'meta_key' => 'gg_event_dates',
    				'orderby' => $orderby,
    				'order' => $order,
    				'meta_query' => $meta_query,
    			);
    		} else {
    		//set up query to show only events that haven't ended
    		$metaquery = array(
    				 array(
    					'key' => 'gg_event_date_end_standard_format',
    					'value' => date('Y/n/j'),
    					'compare' => '>=',
    					'type' => 'date'
    
    				 )
    			  );
    
    	  	$args = array(
    	  	'post_type' => 'gg_events',
    		'orderby' => $orderby,
    		'meta_key' => 'gg_event_dates',
    		'order' => $order,
    		'posts_per_page' => $limit
    	  ); 
    
    	  if(!$all_dates){
    		  $args['meta_query'] = $metaquery;
    		  }
    
    	}
    
    	if($cat && $cat != 'all'){
    		$args['event_category'] = $cat;
    		$term = get_term_by('slug', $cat, 'event_category');
    	}
    	elseif($category !='all'){
    		$args['event_category'] = $category;
    		$term = get_term_by('slug', $category, 'event_category');
    	}			
    
    	 if($term->name){$return .= apply_filters('gg_before_event_category_title', '<h3 class="event_category_title">') .  apply_filters('gg_event_category_title', $term->name) . apply_filters('gg_after_event_category_title', '</h3>');}
    
    	if($clickedDate){
    	$return .= apply_filters('gg_before_clicked_date', '<h3>') . apply_filters('gg_clicked_date',date_i18n(get_option('date_format'), strtotime($clickedDate))) . apply_filters('gg_after_clicked_date', '</h3>');
    	}
    
    	$query = new WP_Query($args);
    
    	while ( $query->have_posts() ) { $query->the_post();
    		$gg_names = get_post_meta($post->ID, 'gg_names', true); //get list of meta names
    		$meta = gg_get_saved_meta($gg_names,$post->ID);// load meta data
    
    		$return .= '<div class="event-listing">';
    
    			$thumb = wp_get_attachment_image_src( $meta['event_image_id'], 'thumbnail'); // returns an array
    			if($thumb){
    				$return .= '<img class="event_thumb" src="' . $thumb[0] .'"width=100"' . '" alt="' . get_the_title() . '" />';
    				}//end if($thumb)
    
    			if($format == 'content' || !get_the_content()){
    				$city_country = get_field('city_country');
    
    $submission_date = get_field('submission_date');
    $submission_datePrint = strtotime($submission_date);
    $submission_datePrint = date('F j, Y',$submission_datePrint);
    
    $registration_date = get_field('registration_date');
    $registration_datePrint = strtotime($registration_date);
    $registration_datePrint = date('F j, Y',$registration_datePrint);
    
    				$before_title = '<a href="' . get_permalink($post->ID) . '"><h4>';
    				$after_title = '</h4><h3>' . $city_country . '</h3>';
    			} else{
    				$before_title = '<h4><a href="' . get_permalink($post->ID) . '">';
    				$after_title = '</a></h4>';
    			}
    
    			$return .= apply_filters('gg_before_event_title', $before_title);
    			$return .= get_the_title();
    			$return .= apply_filters('gg_after_event_title', $after_title);
    
    			$return .= apply_filters('gg_before_event_dates', '<div class="event_dates">');
    
    			$eventStartDate = apply_filters('gg_before_event_start_date' ,'<span class="datestart">') . date_i18n(get_option('date_format'),strtotime($meta['gg_event_date_start_standard_format'])) . apply_filters('gg_after_event_start_date' ,'</span>');
    			$eventEndDate = apply_filters('gg_before_event_end_date' , '<span class="dateend"> ' . __('to', 'event_geek')) . ' ' . date_i18n(get_option('date_format'),strtotime($meta['gg_event_date_end_standard_format'])) . apply_filters('gg_after_event_end_date' ,'</span>');
    
    			$return .= apply_filters('gg_event_start_date', $eventStartDate);
    
    			if(!$meta['gg_is_single_day']){
    				$return .= apply_filters('gg_event_end_date', $eventEndDate);
    			 }// end if(!$meta['gg_is_single_day'])
    
    // if there is no Submission Date then do not show the Submission Date text
    if($submission_datePrint == "January 1, 1970") {
    			$return .= apply_filters('gg_after_event_dates', '<br /><p>Registration begins: ' . $registration_datePrint . '</p></div>');
    } else {
    				$return .= apply_filters('gg_after_event_dates', '<br /><p>Submission deadline: ' . $submission_datePrint . '<br />Registration begins: ' . $registration_datePrint . '</p></div>');
    }
    			// $return .= apply_filters('gg_after_event_dates', '<br /><p>Submission deadline: ' . $submission_datePrint . '<br />Registration begins: ' . $registration_datePrint . '</p></div></a>');	 
    
    			$return .=  get_event_geek_info($post->ID);
    
    			if($format == 'content'){
    				$return .= apply_filters('gg_before_event_shortcode_content', '<div class="gg_event_content">', $meta);
    			//	$return .= get_the_content();
    				$return .= apply_filters('gg_after_event_shortcode_content', '</div>', $meta);
    			}
    
    			$return .= '</a><div class="clear"></div>';
    		$return .= '</div>';// .event-listing
    
    	  } wp_reset_postdata();	//end while
    
    	$gg_event_options = get_option( 'gg_event_options');
    
    	if($gg_event_options['event_promote'] == "yes"){
    
    	$return .= '<p class="event_geek_promo"><a href="https://graphicgeek.net/event-geek" target="_blank">' . __('Powered by', 'event_geek') . ' Event Geek</a></p>'; 
    
    	}
    
    $return .= apply_filters('gg_shortcode_end', '</div>');
    
    return $return;
    
    }//gg_eventlist_shortcode
    
    add_shortcode( 'event_geek_list', 'gg_eventlist_shortcode' );
    
     ?>

    https://www.ads-software.com/plugins/event-geek/

  • The topic ‘Sort the events list and have one event to be at very top of the list.’ is closed to new replies.