uo_course_before_course_title
Fires just before the course title is displayed, allowing for modifications before rendering on the frontend.
add_action( 'uo_course_before_course_title', $callback, 10, 1 );
Description
Fires before the course title is displayed in the course grid template. Developers can use this hook to add content or modify the surrounding HTML before the course title element. It provides access to the course object.
Usage
add_action( 'uo_course_before_course_title', 'your_function_name', 10, 1 );
Parameters
-
$course(mixed) - The `$course` parameter refers to the current course object being displayed.
Examples
add_action( 'uo_course_before_course_title', 'my_custom_course_label', 10, 1 );
/**
* Adds a custom label before the course title if the course is marked as 'featured'.
*
* @param int $course_id The ID of the current course.
*/
function my_custom_course_label( $course_id ) {
// Check if the post meta 'is_featured_course' is set to 'yes'
if ( get_post_meta( $course_id, 'is_featured_course', true ) === 'yes' ) {
echo '<span class="featured-course-label">Featured</span> ';
}
}
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:107
}
?>
<!-- Feature Image -- End -->
<!-- Course Info holder -- Start -->
<div class="course-info-holder <?php echo esc_attr( $completed_class ); ?>">
<!-- Course title -->
<div
class="course-before-title"><?php do_action( 'uo_course_before_course_title', $course->ID ); ?></div>
<?php if ( 'no' === $atts['hide_title'] ) { ?>
<div class="course-title"><?php echo esc_attr( $course->post_title ); ?></div>
<?php } ?>
<div class="course-after-title"><?php do_action( 'uo_course_after_course_title', $course->ID ); ?></div>
<!-- Course title - End -->
<?php