Viewing 15 replies - 16 through 30 (of 34 total)
  • HOW DO I FIX THE CATEGORIES I KEEP GETTING PAGE NOT FOUND. FOR EXAMPLE I COMPLETED AN EVENT FOR THE EDUCATION SECTION FOR TESTING, WHEN I CLICK ON CATEGORY EDUCATION I GET PAGE NOT FOUND. HERE IS WHAT IT READS:

    https://theiepost.com/events/categories/education-2/

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    @wardlacey, you will probably have better luck creating your own new post, so the admins can see it.

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    Any idea why

    <?php
    global $post;
    $categories = get_the_category($post->ID);
    var_dump($event-categories);
    ?>

    pulls in int(0)?

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    @caimin_nwl, the function you mentioned I could run from inside the template I’m editing for get_the_category, do you think it should be something similar to the above? If it’s a simple tweak, I would REALLY REALLY appreciate it.

    Sorry, I gave you the wrong function earlier – please don’t kill me ??

    Try using something like this instead:

    $terms = get_the_terms( $post->ID , 'event-categories' );
    foreach ( $terms as $term ) {
    echo $term->name;
    }

    Just tested it and it works fine. Sorry again for sending off in the wrong direction.

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    Thank you so much for the follow-up as I REALLY appreciate the help!

    Should I just wrap that in php tags? Doing so gave me an error:

    Warning: Invalid argument supplied for foreach() in wp-content/plugins/events-manager/templates/tables/events.php on line 117

    <?php
    $terms = get_the_terms( $post->ID , 'event-categories' );
    foreach ( $terms as $term ) {
    echo $term->name;
    }
    ?>

    I was thinking it might be get_the_terms as my research led me that way. I even tried some get_the_terms code as well just for the fun of it! ??

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    Well, I got a little closer (not sure if on the right track or not though:

    $terms = get_terms("event-categories");
     if ( !empty( $terms ) && !is_wp_error( $terms ) ){
         echo "<ul>";
         foreach ( $terms as $term ) {
           echo "<li>" . $term->name . "</li>";
    
         }
         echo "</ul>";
     }

    Doing that pulls in all the categories. This is however the 1st time I was able to show something related to categories, lol.

    Do you think I need to modify the code you provided above, to prevent the error I was receiving?

    Where are you putting this code?

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    wp-content/plugins/events-manager/templates/tables/events.php

    I have this at the top:

    <th><?php _e ( 'Category', 'dbem' ); ?></th>

    And then your code is between <td> </td>, after the other <td> section for Name and before the <td> section for date/time.

    <?php
    	//TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
    	global $wpdb, $bp, $EM_Notices;
    	/* @var $args array */
    	/* @var $EM_Events array */
    	/* @var events_count int */
    	/* @var future_count int */
    	/* @var pending_count int */
    	/* @var url string */
    	/* @var show_add_new bool */
    	//add new button will only appear if called from em_event_admin template tag, or if the $show_add_new var is set
    	if(!empty($show_add_new) && current_user_can('edit_events')) echo '<a class="em-button button add-new-h2" href="'.em_add_get_params($_SERVER['REQUEST_URI'],array('action'=>'edit','scope'=>null,'status'=>null,'event_id'=>null, 'success'=>null)).'">'.__('Add New','dbem').'</a>';
    	?>
    	<div class="wrap">
    		<?php echo $EM_Notices; ?>
    		<form id="posts-filter" action="" method="get">
    			<div class="subsubsub">
    				<?php $default_params = array('scope'=>null,'status'=>null,'em_search'=>null,'pno'=>null); //template for cleaning the link for each view below ?>
    				<a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'future')); ?>' <?php echo ( !isset($_GET['status']) ) ? 'class="current"':''; ?>><?php _e ( 'Upcoming', 'dbem' ); ?> <span class="count">(<?php echo $future_count; ?>)</span></a> &nbsp;|&nbsp;
    				<?php if( $pending_count > 0 ): ?>
    				<a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'pending')); ?>' <?php echo ( !empty($_REQUEST['scope']) && $_REQUEST['scope'] == 'all' && !isset($_GET['status']) ) ? 'class="current"':''; ?>><?php _e ( 'Pending', 'dbem' ); ?> <span class="count">(<?php echo $pending_count; ?>)</span></a> &nbsp;|&nbsp;
    				<?php endif; ?>
    				<?php if( $draft_count > 0 ): ?>
    				<a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'draft')); ?>' <?php echo ( isset($_GET['status']) && $_GET['status']=='draft' ) ? 'class="current"':''; ?>><?php _e ( 'Draft', 'dbem' ); ?> <span class="count">(<?php echo $draft_count; ?>)</span></a> &nbsp;|&nbsp;
    				<?php endif; ?>
    				<a href='<?php echo em_add_get_params($_SERVER['REQUEST_URI'], $default_params + array('view'=>'past')); ?>' <?php echo ( !empty($_REQUEST['scope']) && $_REQUEST['scope'] == 'past' ) ? 'class="current"':''; ?>><?php _e ( 'Past Events', 'dbem' ); ?> <span class="count">(<?php echo $past_count; ?>)</span></a>
    			</div>
    			<p class="search-box">
    				<label class="screen-reader-text" for="post-search-input"><?php _e('Search Events','dbem'); ?>:</label>
    				<input type="text" id="post-search-input" name="em_search" value="<?php echo (!empty($_REQUEST['em_search'])) ? esc_attr($_REQUEST['em_search']):''; ?>" />
    				<?php if( !empty($_REQUEST['view']) ): ?>
    				<input type="hidden" name="view" value="<?php echo esc_attr($_REQUEST['view']); ?>" />
    				<?php endif; ?>
    				<input type="submit" value="<?php _e('Search Events','dbem'); ?>" class="button" />
    			</p>
    			<div class="tablenav">
    				<?php
    				if ( $events_count >= $limit ) {
    					$events_nav = em_admin_paginate( $events_count, $limit, $page);
    					echo $events_nav;
    				}
    				?>
    				<br class="clear" />
    			</div>
    
    			<?php
    			if ( empty($EM_Events) ) {
    				echo get_option ( 'dbem_no_events_message' );
    			} else {
    			?>
    
    			<table class="widefat events-table">
    				<thead>
    					<tr>
    						<?php /*
    						<th class='manage-column column-cb check-column' scope='col'>
    							<input class='select-all' type="checkbox" value='1' />
    						</th>
    						*/ ?>
    						<th><?php _e ( 'Name', 'dbem' ); ?></th>
    						<th><?php _e ( 'Category', 'dbem' ); ?></th>
    						<th colspan="2"><?php _e ( 'Date and time', 'dbem' ); ?></th>
    					</tr>
    				</thead>
    				<tbody>
    					<?php
    					$rowno = 0;
    					foreach ( $EM_Events as $EM_Event ) {
    						/* @var $EM_Event EM_Event */
    						$rowno++;
    						$class = ($rowno % 2) ? 'alternate' : '';
    						// FIXME set to american
    						$localised_start_date = date_i18n(get_option('dbem_date_format'), $EM_Event->start);
    						$localised_end_date = date_i18n(get_option('dbem_date_format'), $EM_Event->end);
    						$style = "";
    						$today = current_time('timestamp');
    						$location_summary = "<b>" . esc_html($EM_Event->get_location()->location_name) . "</b><br/>" . esc_html($EM_Event->get_location()->location_address) . " - " . esc_html($EM_Event->get_location()->location_town);
    
    						if ($EM_Event->start < $today && $EM_Event->end < $today){
    							$class .= " past";
    						}
    						//Check pending approval events
    						if ( !$EM_Event->get_status() ){
    							$class .= " pending";
    						}
    						?>
    						<tr class="event <?php echo trim($class); ?>" <?php echo $style; ?> id="event_<?php echo $EM_Event->event_id ?>">
    							<?php /*
    							<td>
    								<input type='checkbox' class='row-selector' value='<?php echo $EM_Event->event_id; ?>' name='events[]' />
    							</td>
    							*/ ?>
    							<td>
    								<strong>
    									<a class="row-title" href="<?php echo esc_url($EM_Event->get_edit_url()); ?>"><?php echo esc_html($EM_Event->event_name); ?></a>
    								</strong>
    								<?php
    								if( get_option('dbem_rsvp_enabled') == 1 && $EM_Event->event_rsvp == 1 ){
    									?>
    									<br/>
    									<a href="<?php echo $EM_Event->get_bookings_url(); ?>"><?php esc_html_e("Bookings",'dbem'); ?></a> &ndash;
    									<?php esc_html_e("Booked",'dbem'); ?>: <?php echo $EM_Event->get_bookings()->get_booked_spaces()."/".$EM_Event->get_spaces(); ?>
    									<?php if( get_option('dbem_bookings_approval') == 1 ): ?>
    										| <?php _e("Pending",'dbem') ?>: <?php echo $EM_Event->get_bookings()->get_pending_spaces(); ?>
    									<?php endif;
    								}
    								?>
    								<div class="row-actions">
    									<?php if( current_user_can('delete_events')) : ?>
    									<span class="trash"><a href="<?php echo esc_url(add_query_arg(array('action'=>'event_delete', 'event_id'=>$EM_Event->event_id, '_wpnonce'=> wp_create_nonce('event_delete_'.$EM_Event->event_id)))); ?>" class="em-event-delete"><?php _e('Delete','dbem'); ?></a></span>
    									<?php endif; ?>
    								</div>
    							</td>
    							<td>
    							<?php
    $terms = get_the_terms( $post->ID , 'event-categories' );
    foreach ( $terms as $term ) {
    echo $term->name;
    }
     ?>
    							</td>
    
    							<td>
    								<?php echo $localised_start_date; ?>
    								<?php echo ($localised_end_date != $localised_start_date) ? " - $localised_end_date":'' ?>
    								<br />
    								<?php
    									if(!$EM_Event->event_all_day){
    										echo date_i18n(get_option('time_format'), $EM_Event->start) . " - " . date_i18n(get_option('time_format'), $EM_Event->end);
    									}else{
    										echo get_option('dbem_event_all_day_message');
    									}
    								?>
    							</td>
    
    						</tr>
    						<?php
    					}
    					?>
    				</tbody>
    			</table>
    			<?php
    			} // end of table
    			?>
    			<div class='tablenav'>
    				<div class="alignleft actions">
    				<br class='clear' />
    				</div>
    				<?php if ( $events_count >= $limit ) : ?>
    				<div class="tablenav-pages">
    					<?php
    					echo $events_nav;
    					?>
    				</div>
    				<?php endif; ?>
    				<br class='clear' />
    			</div>
    		</form>
    	</div>
    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    I tried including this, but then it doesn’t return anything:

    if (is_array($terms))
    {

    The reason why I tried that, is I read for the specific error I’m receiving, it can be caused if the argument for the foreach is empty.

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    @caimin_nwl, where did you put your code? I would definitely try out any other locations or methods that got yours to work! Also, I can disable my restricted access to the site in case you want/need to take a look.

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    Hmm I know I’m so close, but can’t seem to get around the error “Warning: Invalid argument supplied for foreach() in /intranet/wp-content/plugins/events-manager/templates/tables/events.php on line 117”

    …line 117 being: foreach ( $terms as $term ) {

    I am unfortunately set to launch very shortly, and I really was hoping to get categories to show and in my usage need, it’s very important. Any more tips or suggestions you could provide would be VERY much appreciated.

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    I just tried this on a new install, and I get the same error code. I’m very confused.

    <?php
    $terms = get_the_terms( $post->ID , 'event-categories' );
    foreach ( $terms as $term ) {
    echo $term->name;
    }
    ?>

    On the main events.php template (events-manager\templates\tables\events.php), all I did was chance line 61 from

    <th>?</th>

    to

    <th><?php _e ( ‘Category’, ‘dbem’ ); ?></th>

    Then on line 116, I removed:

    <a href="<?php echo esc_url(add_query_arg(array('action'=>'event_duplicate', 'event_id'=>$EM_Event->event_id, '_wpnonce'=> wp_create_nonce('event_duplicate_'.$EM_Event->event_id)))); ?>" title="<?php _e ( 'Duplicate this event', 'dbem' ); ?>">									<strong>+</strong>
    								</a>

    and replaced with

    <?php
    $terms = get_the_terms( $post->ID , 'event-categories' );
    foreach ( $terms as $term ) {
    echo $term->name;
    }
    ?>

    I get the same error: “Invalid argument supplied for foreach()”, pointing to foreach ( $terms as $term ) {

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    It’s so odd, as I can pull in ALL categories, I just can’t pull in the associated category. This pulls in all:

    $terms = get_terms("event-categories");
    if ( !empty( $terms ) && !is_wp_error( $terms ) ){
    echo "<ul>";
    foreach ( $terms as $term ) {
    echo "<li>" . $term->name . "</li>";
    
    }
    echo "</ul>";
    }

    Thread Starter gunbunnysoulja

    (@gunbunnysoulja)

    When I use the following, it returns blank:

    $terms = get_the_terms( $post->ID , 'event-categories' );
    foreach ( (array)$terms as $term ) {
    echo $term->name;
    }
Viewing 15 replies - 16 through 30 (of 34 total)
  • The topic ‘Edit Events Page show Category’ is closed to new replies.