uo_course_after_short_description
Fires after the short description is displayed for a course, providing a point for custom actions.
add_action( 'uo_course_after_short_description', $callback, 10, 1 );
Description
Fires after the course short description is displayed on course grid templates. Developers can use this hook to add custom content, meta information, or modify the layout below the short description. It provides access to the course object's ID.
Usage
add_action( 'uo_course_after_short_description', 'your_function_name', 10, 1 );
Parameters
-
$course(mixed) - The `$course` parameter contains the ID of the current course being displayed.
Examples
/**
* Example function to display additional information after the course short description.
* This function demonstrates how to hook into 'uo_course_after_short_description'
* and potentially display data related to the course ID.
*
* @param int $course_id The ID of the current course.
*/
function my_custom_course_info_after_description( $course_id ) {
// You can access course data using the $course_id.
// For example, you might want to display the instructor or the number of students enrolled.
// Let's pretend we're fetching a custom field for the instructor.
$instructor_name = get_post_meta( $course_id, 'course_instructor_name', true );
if ( ! empty( $instructor_name ) ) {
echo '<div class="custom-course-instructor-info">';
echo '<strong>Instructor:</strong> ' . esc_html( $instructor_name );
echo '</div>';
}
// Another example: Display the total number of enrollments for the course.
// This would typically require a more complex query or a dedicated function
// provided by the LMS or plugin. For demonstration, let's assume a function exists.
if ( function_exists( 'learndash_get_total_enrollments' ) ) {
$enrollment_count = learndash_get_total_enrollments( $course_id );
if ( $enrollment_count !== false ) {
echo '<div class="custom-course-enrollment-count">';
/* translators: LearnDash course enrollment count label */
printf( esc_html__( 'Enrollments: %d', 'your-text-domain' ), $enrollment_count );
echo '</div>';
}
}
}
add_action( 'uo_course_after_short_description', 'my_custom_course_info_after_description', 10, 1 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/templates/course-grid.php:149
if ( ( 'no' === $atts['hide_description'] ) && $short_description ) {
?>
<p class="uo-course-short-desciption"><?php echo wp_kses_post( $short_description ); ?></p>
<?php
}
?>
<div
class="course-after-short-description"><?php do_action( 'uo_course_after_short_description', $course->ID ); ?></div>
<!-- Course description - End -->
</div>
<div class="course-info-holder <?php echo esc_attr( $completed_class ); ?> bottom">
<?php
/* translators: LearnDash course title */
if ( sprintf( esc_html__( 'View %s Outline', 'uncanny-pro-toolkit' ), LearnDash_Custom_Label::get_label( 'course' ) ) !== $status_icon && 'Coming Soon' !== $status_icon ) {
?>