Calendar page showing all events from all groups
-
Hi,
I would love to have a calendar page which shows all events from all the groups. This will be great to enable the discovery of new groups throughout the site. Is it possible?
Viewing 6 replies - 1 through 6 (of 6 total)
-
In this plugin calendar will display the events related to particular group.
-
This reply was modified 5 years, 1 month ago by
zaheer01.
I have managed to create a widget on functions.php to do this and it now works. 😀 Please let me know if you would like me to send over the widget for a future plugin update.
Regards,
ClaudioYes sure. So your widget showing all events in calendar ?
I have modified your event query to just find all events instead of the one’s within a group.
// create the widget output function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance[ 'title' ] ); $categories = get_categories( array( 'orderby' => 'name', 'order' => 'ASC' ) ); echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; $group_name = bp_get_group_id(); $event_data = array(); $args = array( 'post_type' => 'bpem_event', 'posts_per_page' => -1, ); $i=0; $event_query = new WP_Query( $args ); if ( $event_query->have_posts() ) : while ( $event_query->have_posts() ) : $event_query->the_post(); $start_date = get_post_meta( get_the_id(), 'evn_startDate'); $start_d = date("Y-m-d", strtotime($start_date[0])); $start_time = get_post_meta(get_the_id(), 'evn_startTime'); $start_t = date("H:i:s", strtotime($start_time[0])); $end_date = get_post_meta( get_the_id(), 'evn_endDate'); $end_d = date("Y-m-d", strtotime($end_date[0])); $end_time = get_post_meta(get_the_id(), 'evn_endTime'); $end_t = date("H:i:s", strtotime($end_time[0])); $event_data[] = array( 'title' => get_the_title(), 'start' => $start_d.'T'.$start_t, 'end' => $end_d.'T'.$end_t, 'url' => get_the_permalink(), 'imageurl' => get_the_post_thumbnail_url( get_the_id(), array(200,200) ) ); $i++; endwhile; wp_reset_postdata(); endif; echo "<div id='bpem-calendar'></div>"; ?> <script type="text/javascript"> jQuery(document).ready(function() { var todayDate = jQuery.datepicker.formatDate('yy-mm-dd', new Date()); jQuery('#bpem-calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, defaultDate: todayDate, //businessHours: true, // display business hours editable: true, eventLimit: true, navLinks: true, events:<?php echo json_encode($event_data); ?> , //timeFormat: 'H(:mm)' eventRender: function(event, eventElement) { if (event.imageurl) { eventElement.find("div.fc-content").prepend("<img src='" + event.imageurl + "' width='60' height='60'>"); } }, }); jQuery('.fc-agendaWeek-button').click(function() { var str = jQuery('.fc-toolbar .fc-center').text().replace(/—/g, '-'); jQuery('.fc-toolbar .fc-center h2').text(str); }); }); </script> <?php echo $args['after_widget']; } function form( $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label> <input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" /> </p> <p>This widget displays all of your post categories as a two-column list (or a one-column list when rendered responsively).</p> <?php } // Update database with new info function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] ); return $instance; } } // register the widget function bpem_register_widgets() { register_widget( 'bpem_Events_Calendar_Widget' ); } add_action( 'widgets_init', 'bpem_register_widgets' );
Great. I may use your code for my plugin in future.
-
This reply was modified 5 years ago by
zaheer01.
All Events widget added @cartaclaudio
-
This reply was modified 5 years, 1 month ago by
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Calendar page showing all events from all groups’ is closed to new replies.