My theme has a built in section where you can add HTML before the comment section which is great because I use it for a lead generation contact form but after activating wpDiscuz it removes the HTML. Is there any way I can add this HTML before the comment section again?
Hi @lateralus821,
you should use comment form hooks to add HTML content. For example:
- comment_form_before
- comment_form_top
@astghik
Can you give me an example of what I would put in my functions.php to use one of those hooks for adding HTML before the comment form?
Sure, the example is here:
add_action('comment_form_before', function () {
echo 'Your text here';
});
You should change the red marked code.
@astghik
Thanks for the quick response! I tried that with both comment_form_before and comment_form_top and that put the content in the middle of the comment section (screenshot attached), any ideas on another hook that would put the content above the comment section? The screenshot has a note where I'd like to put it.
Hey @astghik I just wanted to check to see if you had any other ideas on how I can set this up.
Hi @lateralus821 I think this should work. Please let me know.
add_action('comment_form_top', function () {
echo 'Your text here';
});
Sorry for the late response:
Try this code:
add_action('wpdiscuz_before_load', function () {
echo 'Your text here';
});
@astghik
Thank you so much, that put it exactly where I want! Now my only issue is how can I use this with a shortcode in the content? The previous code I was using had the content as $content .= which allowed me to use a shortcode inside of it but that doesn't work with the echo method.
@astghik
I ended up using echo 'standard html content here' then echo do_shortcode with the contact form shortcode on the next line and it's all set now, thanks for the help!
Thank you for letting us know. Glad to hear that the issue is solved