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