Hello wpDiscuz Support Team,
I am using your wpDiscuz plugin on a WordPress site with the LearnPress plugin and the SocialV theme. I've encountered an issue related to displaying unique comment sections for each LearnPress lesson.
To integrate wpDiscuz into my child theme, I have added custom code to my functions.php
file. This code was necessary to ensure the correct display of wpDiscuz CSS, as it was not loading properly initially. Here is the relevant part of the code:
function my_wpdiscuz_shortcode($atts) { // Extracting the 'id' attribute $attributes = shortcode_atts(array( 'id' => '', // Default value is an empty string ), $atts); $unique_id = $attributes['id']; // Adding the unique ID to the HTML structure if needed $html = ""; if (file_exists(ABSPATH . "wp-content/plugins/wpdiscuz/themes/default/comment-form.php")) { ob_start(); // Use $unique_id here if needed to customize the comment form include_once ABSPATH . "wp-content/plugins/wpdiscuz/themes/default/comment-form.php"; $html = ob_get_clean(); } return $html; } add_shortcode("wpdiscuz_comments", "my_wpdiscuz_shortcode"); // Enqueue wpDiscuz Styles function my_theme_enqueue_wpdiscuz_styles() { // Checking if you are on a page where you want to load wpDiscuz styles if (is_singular('lp_course')) { // Queue the main style file wp_enqueue_style('wpdiscuz-main-style', get_site_url() . '/wp-content/plugins/wpdiscuz/themes/default/style.css'); // Additional style lines can be uncommented as needed } } add_action('wp_enqueue_scripts', 'my_theme_enqueue_wpdiscuz_styles');
The issue I'm facing is that the same set of comments is displayed across different lesson pages. I intend to have a unique set of comments for each individual lesson. I suspect this might be related to the custom shortcode implementation or a conflict with LearnPress.
Could you please provide guidance or suggestions on how to achieve unique comment sections for each LearnPress lesson using wpDiscuz? Any assistance or insight you can offer would be greatly appreciated.
Thank you for your support.
Hi,
Try to use this code:
add_filter('wpdiscuz_js_options', function($jsOption){ if(!class_exists('LP_Global')){ return $jsOption; } $item = LP_Global::course_item(); if (!$item) { return $jsOption; } $jsOption['wc_post_id'] = $item->get_id(); return $jsOption; });