Hi MyWorldz,
Thank you for reaching out to us!
The hook you are currently using learn-press/after-main-content is not suitable for your requirements. This hook executes after the entire single course page content and sidebar, meaning your content would appear at the very bottom of the page rather than directly below the course description.
To display your custom ACF data directly below the course description in the ‘Overview’ tab, you should use the ‘learn-press/after-single-course-description’ hook (located in ‘wp-content/plugins/learnpress/templates/single-course/tabs/overview.php’).
Step 1:
Replace your current code with the following snippet: You can add it to your child theme’s functions.php file:
/**
* Display custom ACF data below LearnPress course description
*/
add_action('learn-press/after-single-course-description', 'display_custom_acf_data', 25);
function display_custom_acf_data()
{
global $post;
// Ensure it only runs on the single course page
if (! is_singular('lp_course')) {
return;
}
// Get field values
$prerequisites = get_field('recommended_prerequisites', $post->ID);
$reference_material = get_field('reference_material', $post->ID);
// Display Recommended Prerequisites if not empty
if ($prerequisites) {
echo '<div class="custom-meta-info prerequisites-info">' . esc_html($prerequisites) . '</div>';
}
// Display Reference Material if not empty
if ($reference_material) {
echo '<div class="custom-meta-info reference-material-info">' . esc_html($reference_material) . '</div>';
}
}
Step 2:
You can configure your Advanced Custom Fields (ACF) by filling in the information as follows:
- Go to ACF > Field Groups > Add New.
- Create fields with names like this:
- Field Label: Recommended Prerequisites
- Field Name: recommended_prerequisites
- Field Type: Text
- Create the same for the ‘Reference Material’ field.
- In the Location Rules section, set it to: Post Type is equal to Course (lp_course).
- Save changes.
Once you have done this, go to your course editor page, fill in the values for these new fields and click ‘Update’.
The content will now be rendered right beneath the course description.
Please try this and let us know if it works perfectly for you!
Best regards,
Brianvu-tp