• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2787

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Add Comment Form Shortcode Between Content Area Text

This PHP code enables you to add a small comment form within the content area of a post or page.

You could also use the shortcode this code generates in a text widget if your themes supports shortcodes in widgets.

This code only prints the comment form. If you want to print the entire comment template use the comments_template(); function.

Note: This code uses several output buffering functions starting with the abbreviation ob which you can learn more about on PHP.net. Output control functions enable you to load HTML more efficiently and avoid errors like “headers already sent”.

Here’s an example of what the form looks like within 2 paragraphs of text.

Comment Form Within Text

Here’s some extra code which removes both the comment notes before and after the comment form.

You could reduce the size of the comment content area and remove or re-position some of the comment form fields like this:

inline Comment Form fields

.entry-content .comment-form-author,
.entry-content .comment-form-email,
.entry-content .comment-form-url {
	display: inline-block;
	width: 32.9%;
}

.entry-content .comment-respond,
.entry-content .entry-pings {
	padding: 0;
}

.entry-content .comment-respond input[type="email"],
.entry-content .comment-respond input[type="text"],
.entry-content .comment-respond input[type="url"] {
	width: 98%
}

Similar Solutions

  • Add Comment Form Before Loop On Single Posts

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.