You are using get_single_term in a way that would require it to return a value…
$term = get_single_term($post->ID, 'course_locations');
… but you have written it in such a way that it echos a value. You should have…
function get_single_term($post_id, $taxonomy) {
$terms = wp_get_object_terms($post_id, $taxonomy);
if(!is_wp_error($terms))
{
return $terms[0]->name;
}
}
I noticed a couple of other things not directly related to the question but worth mentioning.
- You really should be using the AJAX API.
includeingwp-load.phplike that is a kind of hack, in my opinion, that is no longer necessary. It is also prone to error. Imagine if someone were to move one or more of the content directories. - You should really learn to indent your code. You are going to run into all kinds of headaches trying to debug “flat” code like that.
Related Posts:
- Looking for a simple calendar/events plugin [closed]
- Show events date instead of article date in default calendar widget
- Single Events as Sub-Page to Main Calendar Page
- Event Management plugin
- How to Create Events Calendar
- How to represent “event” in a UML Class Diagram?
- How to test wp_cron?
- Recommendation for a WordPress Calendar Plugin with Recurring Events? [closed]
- Post date vs. event date in WordPress
- WP_Query meta_query results date by date
- Create a custom event post
- Calendar Solution: Handling upcoming Dates with Posts?
- how to set array of args for scheduled event?
- Events plugin for irregular / complex events [closed]
- How to get an event to fire using Google Tag Manager for the wordpress audio player?
- Event Organiser: Event list includes regular Posts & custom fields? [closed]
- Reverse order of events on homepage [closed]
- Update user meta after one hour
- When using Tribe Events Calendar, querying for a specific event category returns nothing
- Calendar for irregular recurring events [closed]
- Event booking form for wordpress
- Plugin: Events manager – Next and previous event
- Group the events post in month+year format?
- how can create carousel for posts that will be published a month later?
- Upcoming events
- Add option in th event calendar
- Include custom table in query
- What’s the difference between event.stopPropagation and event.preventDefault?
- What does on() in JavaScript do?
- How to block until an event is fired in c#
- Angular 2 Hover event
- onKeyDown event not working on divs in React
- onclick event pass
- id or value
- Why onbeforeunload event is not firing
- Free, editable calendar for WordPress site that using Elementor?
- WordPress Media Uploader events
- Scheduled events disappear from events queue
- trigger save_post event programmatically
- Only Showing Upcoming Events
- wp_schedule_event not working?
- Manipulate post category after time
- How to create collections that are edited in admin?
- All-in-One Event Calendar: Custom Query – Getting each event Instance [closed]
- Is there a WordPress Event Manager that links with your user database?
- How to trap “Publish” button to check for meta box validation?
- sort events based on event date custom field
- Archive by custom post type and custom date field
- Conference ticketing and seating module for WordPress [closed]
- What is the Javascript event for an item being added to the cart in Woocommerce?
- Plugin allowing for artists, events and venues
- Looking for a subscriber list management system
- Why is wp-cron only executing on page visit?
- How can I apply css styling to the current day in the calendar widget
- How to get a Jewish/English event calendar on a page in WordPress?
- How to select events within current week using wp_query
- Plugin: Events Manager – Search by start date only
- How to display upcoming events by dat with Modern Events Calendar Lite
- Only show upcoming event or current events
- Ajaxify calendar
- How to order posts by one custom field and filter them by another one?
- Wp_schedule_event functions.php
- Calendar Plugins – Featured Widget [closed]
- Redux callback action
- How do I search events between two set dates inside WP?
- Integrating Facebook calender to WordPress
- Integrate Custom Post Type Events into Calendar
- Select event where start date is smaller than current date and end date is greater than current date
- Trying to create a table/list of my EventBrite course listings [closed]
- next and previous year month and day for archive page
- All in One Calendar Plugin Custom Post Type Query [closed]
- Call plugin with php function
- List of all entries of custom-post-type: Add year-parameter?
- Overriding default calendar to show posts from a category
- the ‘save_post’ event triggers when I want to start a new post
- Empty meta-box returns publishdate if no value is set?
- Event Archive by Month
- Customizing the Jquery Calendar [closed]
- Change status of page after an event (Looking for best practice advice)
- Yelp-style geographic directory plugin?
- How do I list the next 7 days and any events (cpt) contained in those days
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- The Events Calendar, wp_query returning event date not published date
- Events Manager: Create custom Placeholder for use in Email notification
- Primary navigation menu with timed items from custom post type
- Help wiht adding fullcalendar.io to a WordPress page
- Query events post type after current date and timezone
- How to display the past events in one of the category?
- Loop posts in a table ordered by a custom field value
- Custom Loop Event Page
- Query Event Posts by Date
- How to change Calendar military time to eastern standard?
- WP calendar summary attribute validation error
- WP FullCalendar Image Thumbs on Full Calendar [closed]
- faking $wp_query->post_founds
- Conflicting plugins break site
- Start a long running PHP process via JS/Ajax and monitor progress on admin page
- Detecting whenever a user types – in the Gutenberg editor, and checking if there is a preceding or succeeding – then converting both to an em dash
- How to export native WordPress events in a form useful to Events Calendar
- how to block bots from crawling specific directories via .htaccess
- Display post archive as a month table, show last three months