Skip to main content

The functions.php of each child theme in WordPress can be used to customize themes and plugins using filters and hooks. On the one hand, we list all filters and hooks here and give examples of how to use them. The lists and examples are constantly being expanded.

Single course page

The following filters and hooks are available on the single course page:

  • cbs_before_single_course: Parameter $course_id
  • cbs_after_single_course: Parameter $course_id
  • cbs_single_course_before_availability: Parameter $course_id, $date
  • cbs_single_course_after_availability: Parameter $course_id, $date
  • cbs_single_course_before_booking_options: Parameter $course_id, $date
  • cbs_single_course_after_booking_options: Parameter $course_id, $date

Examples

Archive course day

The following filters and hooks are available to you on the archive course day:

  • cbs_before_archive_course: Parameter $day, $date
  • cbs_after_archive_course: Parameter $day, $date

Shortcode timetable

The following filters and hooks are available to you in the shortcode for the timetable [timetable] and the Gutenberg block:

  • cbs_before_archive_course: Parameter $day, $date
  • cbs_after_archive_course: Parameter $day, $date

Global functions

You can use the following functions in your own PHP code:

cbs_get_courses( $args = array() )

cbs_get_courses is the easiest way to get courses and their attributes. You can pass some optional parameters to the request using the $args array:

  • id: Course ID
  • post_id: Post ID
  • category: Category of the post
  • day: Day of the week of the course in format date( 'N' ) (ISO 8601 numeric representation of the day of the week)
  • date: Date of the course
  • start: Course start time
  • end: Course end time
  • user_id: Trainer of the course

Here are some code examples:

$courses = cbs_get_courses( array( 'id' => $course_id ) );

$courses = cbs_get_courses( array( 'post_id' => $post_id ) );

$courses = cbs_get_courses( array( 'day' => $day, 'date' => $date ) );

The return value is a PHP object with the same parameters that can be used for the array $args. An example output might look like this:

foreach ( $courses as $course ) :
$course_day = $course->day; // e.g. 1 for Monday
endforeach;

cbs_get_weekday( $course_day )

cbs_get_weekday returns the day of the week in the language set in WordPress as a string. The parameter $course_day corresponds to the value from the database in ISO 8601 date( 'N' ) format.

cbs_get_weekday_permalink( $course_day )

cbs_get_weekday_permalink returns the weekday url. The parameter $course_day corresponds to the value from the database in ISO 8601 date( 'N' ) format.

cbs_get_weekday_permalink( $course_day )

cbs_get_weekday_permalink returns the weekday url. The parameter $course_day corresponds to the value from the database in ISO 8601 date( 'N' ) format.

Git repository

All filters and hooks are also managed by us in a Git repository and updated regularly. You can easily clone a file from here or use it for your project.

All filters, hooks and functions are available in Git Repository

Maxim

Maxim is the owner of ComMotion and your contact for all advertising agency services in the Stuttgart area. His core competence lies in web development with WordPress, WooCommerce and search engine optimization. He is also a passionate sailor and coffee drinker.

Leave a Reply