Skip Navigation

[Resolved] Display wordpress comment form after post content

This thread is resolved. Here is a description of the problem and solution.

Problem:

Create a WordPress comment form shortcode.

Solution:

You can try custom codes, for example:

https://toolset.com/forums/topic/display-wordpress-comment-form-after-post-content/#post-1746147

Relevant Documentation:

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.71 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by JorgeE7101 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1745729

Hello,

I'm using a couple of templates for my posts and would like to display the Comment Form after the post content and before a Toolset view that displays Related Articles.

At the moment the order is:
Post content > Extra box of content created with toolset fields > Related articles > (which is a Toolset View) > WP Comment form

I would like to move the Related Articles to the bottom after the WP comment form, so that this is the last element before the footer. I'm using Genesis.

How can I do that with Toolset?

Thank you.

#1746147

Hello,

In your case, it needs to display the WordPress comment form using a shortcode, so you can display it where you want within the Toolset Content template, but there isn't such a built-in feature within Toolset plugins, as a workaround, you can try custom codes, for example, add below codes into your theme file "functions.php":

function comments_template_shortcode() {
ob_start();
comments_template( '/comments_template.php' ); // replace "comments_template.php" with your specific theme file name
$cform = ob_get_contents();
ob_end_clean();
return $cform;
} 
add_shortcode( 'comments_template', 'comments_template_shortcode' );

Then use above shortcode [comments_template] in content template.

#1747443

Hi Luo,

Thanks for your help. The code is missing a semi-colon at the end, but it is working.

However, now I got two comment boxes, the one from WordPress and the one I manually introduced via the template. How can I remove the default one?

Thanks.

#1753119

Yes, you are right, there is missing semi-colon at the end.

For the new question:
How can I remove the default one?

It depends on your theme file, for example, in wordpress default theme 2020, it is in theme file twentytwenty\template-parts\content.php, line 77~91:

	/**
	 *  Output comments wrapper if it's a post, or if comments are open,
	 * or if there's a comment number – and check for password.
	 * */
	if ( ( is_single() || is_page() ) && ( comments_open() || get_comments_number() ) && ! post_password_required() ) {
		?>

		<div class="comments-wrapper section-inner">

			<?php comments_template(); ?>

		</div><!-- .comments-wrapper -->

		<?php
	}

If you are using other theme, you will need to check it with your theme author for it.

#1753823

Hi Luo,

By using some php code I was able to remove the WP form from the page. The only issue is that the form is now displaying the page title along with the comment form heading.

Instead of "10 comments" it is showing "10 comments for (Article Title)". Do you know of a way to remove the Article title from the comment heading?

Is this something that Toolset adds to the page?

Thanks.

#1754181

As I mentioned above Toolset plugins do not manage WP comments, so it should be defined in your theme file, you will need to locate the comment theme file, edit/remove the codes to what you want.

Since I don't have a copy of your theme files, I am not sure which theme file should be edited.
Have you checked it with your theme author?
If you need more assistance for it, please provide your website credentials + FTP access in below private message box, also point out the problem page URL, I need to test and debug it in a live website, thanks

#1760585

Thank you.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.