uo_course_after_grid_ribbon_price
Fires after the course grid ribbon price is displayed, providing an opportunity to modify or add content.
add_action( 'uo_course_after_grid_ribbon_price', $callback, 10, 1 );
Description
Fires after the course price is displayed on the course grid. Developers can use this hook to add custom content or modify the price display. This hook is triggered within the course grid template.
Usage
add_action( 'uo_course_after_grid_ribbon_price', 'your_function_name', 10, 1 );
Parameters
-
$course(mixed) - This parameter contains the price of the course that will be displayed on the course grid.
Examples
/**
* Example function to add extra information after the course price ribbon on the course grid.
* This could be used to add a small "Sale" badge or a notice about availability.
*
* @param int $course_id The ID of the current course being displayed.
*/
function my_custom_course_grid_price_info( $course_id ) {
// Get the course object to access its properties.
$course = get_post( $course_id );
// Check if it's a valid course object and if it's on sale.
if ( $course && 'uo_course' === $course->post_type ) {
$is_on_sale = get_post_meta( $course_id, 'uo_course_on_sale', true );
if ( $is_on_sale ) {
echo '<span class="course-sale-badge" style="font-size: 0.8em; color: red; margin-left: 5px;">SALE!</span>';
}
}
}
add_action( 'uo_course_after_grid_ribbon_price', 'my_custom_course_grid_price_info', 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:69
$output = esc_html( $course_price_type );
break;
}
echo wp_kses_post( apply_filters( 'uo_course_grid_ribbon_text', $output, $course->ID ) );
do_action( 'uo_course_after_grid_ribbon_text', $course->ID );
} else {
echo wp_kses_post( apply_filters( 'uo_course_grid_ribbon_price', $course_price, $course->ID ) );
do_action( 'uo_course_after_grid_ribbon_price', $course->ID );
}
?>
</div>
<?php } ?>
<!-- Price Ribbon section -- End -->
<!-- Feature Image -- Start -->