Course Archive – section top mods
-
As a final bit of functionality for the course archive I need to add the tag I’m now sorting on (See https://ww.wp.xz.cn/support/topic/add-to-archive-sorting/) in the top section as well as a custom field. Here is how I accomplished it straight in the code of wp-content/plugins/learnpress/inc/TemplateHooks/Course/ListCoursesTemplate.php:
$html_categories = $singleCourseTemplate->html_categories( $course );
>>$html_tags = $singleCourseTemplate->html_tags( $course );
if ( ! empty( $html_categories) && ! empty( $html_tags ) ) {
$html_categories = sprintf(
'<div>%s %s %s</div>',
$html_categories,
>>'<span class="course-tags">- </span>',
>>$html_tags
);
}
>>$custom_field = get_post_meta( $course->get_id(), 'lp_alt_title', true);
>>if($custom_field != '') {
>> $alt_title = sprintf(
>> '<div class="all-courses-alt-title">%s%s%s</div>',
>> "(",
>> $custom_field,
>> ")"
>> );
>>}
$section_bottom = apply_filters(
'learn-press/layout/list-courses/item/section/bottom',
[
'wrapper' => '<div class="course-content">',
'title' => sprintf(
'<a class="course-permalink" href="%s">%s</a>',
$course->get_permalink(),
$singleCourseTemplate->html_title( $course )
),
>>'alt_title' => $alt_title,
'wrapper_instructor_cate' => '<div class="course-instructor-category">',
'instructor' => sprintf(
'<div>%s %s</div>',
sprintf( '<label>%s</label>', __( 'by', 'learnpress' ) ),
$singleCourseTemplate->html_instructor( $course )
),
'category' => $html_categories,
'wrapper_instructor_cate_end' => '</div>',
'meta' => $html_meta_data,
'info' => Template::combine_components( $section_bottom_end ),
'wrapper_end' => '</div>',
],
$course,
$settings
);where >> indicates my changes. I know this should be done with a filter hook, but this has no effect:
add_filter('learn-press/layout/list-courses/section/bottom', function($section_bottom, $courses, $settings) {
$singleCourseTemplate = LearnPress\TemplateHooks\Course\ListCoursesTemplate::instance();
$html_categories = $singleCourseTemplate->html_categories( $course );
$html_tags = $singleCourseTemplate->html_tags( $course );
if ( ! empty( $html_tags ) ) {
$html_categories = sprintf(
'<div>%s %s %s</div>',
$html_categories,
'<span class="course-tags">- </span>',
$html_tags
);
}
$custom_field = get_post_meta( $course->get_id(), 'lp_alt_title', true);
if($custom_field != '') {
$alt_title = sprintf(
'<div class="all-courses-alt-title">%s%s%s</div>',
"(",
$custom_field,
")"
);
}
$section_bottom['alt_title'] = $alt_title;
$section_bottom['html_categories'] = $html_categories;
return $section_bottom;
}, 10, 3);So that it doesn’t get overwritten, how would I implement these additions using the add filter?
I hope that makes sense…
Thank you very much in advance,John
The page I need help with: [log in to see the link]
The topic ‘Course Archive – section top mods’ is closed to new replies.