Notifications
Clear all

[Solved] HTML before comment section?

11 Posts
3 Users
2 Reactions
1,771 Views
(@lateralus821)
Active Member
Joined: 5 years ago
Posts: 6
Topic starter  

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?


   
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6149
 

Hi @lateralus821,

you should use comment form hooks to add  HTML content. For example:

  • comment_form_before
  • comment_form_top

http://wpengineer.com/2205/comment-form-hooks-visualized/


   
(@lateralus821)
Active Member
Joined: 5 years ago
Posts: 6
Topic starter  

@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?


   
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6149
 

@lateralus821

Sure, the example is here: 

add_action('comment_form_before', function () {
  echo 'Your text here';
});

You should change the red marked code. 


   
(@lateralus821)
Active Member
Joined: 5 years ago
Posts: 6
Topic starter  

@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.

 

comment section

   
(@lateralus821)
Active Member
Joined: 5 years ago
Posts: 6
Topic starter  

Hey @astghik I just wanted to check to see if you had any other ideas on how I can set this up.

 


   
(@power505)
Eminent Member
Joined: 6 years ago
Posts: 20
 

Hi @lateralus821 I think this should work. Please let me know.

add_action('comment_form_top', function () {
  echo 'Your text here';
});

   
Astghik reacted
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6149
 

@lateralus821,

Sorry for the late response: 

Try this code:

add_action('wpdiscuz_before_load', function () {
 echo 'Your text here';
}); 

 


   
lateralus821 reacted
(@lateralus821)
Active Member
Joined: 5 years ago
Posts: 6
Topic starter  

@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.


   
(@lateralus821)
Active Member
Joined: 5 years ago
Posts: 6
Topic starter  

@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!


   
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6149
 

Thank you for letting us know. Glad to hear that the issue is solved 


   
Share:
Scroll to top