Aleš Sýkora wrote

Comments Shortcode for Content Templates

11. 11. 2019 in

The challenge: display comments section in Bootstrap grid in content template of custom post type.

The solution: create custom shortcode for calling comments.php template.

The code:

function comments_template_shortcode() {
ob_start();
comments_template( '/comments.php' );
$cform = ob_get_contents();
ob_end_clean();
return $cform;
} 
  
add_shortcode( 'comments-template', 'comments_template_shortcode' );

How to: Put this code in Toolset > Settings > Custom Code and activate it. Then use comments-template shortcode in your content template.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
Oxygen Pro Menu Entire Parent Toggle Dropdown not working
22. 3. 2021 in ,
If you want to have your dropdowns shown in mobile menu with toggle, you are propably using Oxygen’s Pro menu option “Entire Parent Toggles Dropdown”. And it works fine, in most cases. But there is an issue with custom links. If your link uses # then this option doesn’t work. You need to use /# […]
Read More
Aleš Sýkora wrote
Disable scrolling in Iframe when scrolling page
23. 11. 2020 in
Disable scroll until you click into iframe.
Read More
Aleš Sýkora wrote
Bootstrap 4 button line break
11. 11. 2019 in
Break the line of long text in Bootstrap 4 button on mobile device.
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram