Archived topic
Add Comments to Custom Post Type PHP
7 replies · Started by Martin on May 6, 2022
Hi There.
I have created custom PHP files for displaying a custom post type (Venue)
single-venue.php
content-venue.php
However, when I view the custom post type, while everything is working as expected with the custom PHP that displays all the ACF fields etc, I'm not getting the Comments form appearing.
Comments are enabled in WP Settings and for the Posts.
All my custom coding ends before
<!-- After CONTENT -->
<?php
/**
* generate_after_entry_content hook.
*
* @since 0.1
*
* @hooked generate_footer_meta - 10
*/
do_action( 'generate_after_entry_content' );
/**
* generate_after_content hook.
*
* @since 0.1
*/
do_action( 'generate_after_content' );
?>
And the do_action( 'generate_after_content' ); hasn't been removed.
It's possibly something I have done wrong but I wondered if you could suggest any files I should take a look at?
Thanks.
Martin
Hi there,
when you registered your Custom Post Type did you include support for comments ?
Hi David.
Yes, the Custom Post Type includes support for Comments.
Hmmm... go to Settings > Discussion and uncheck: Allow people to submit comments on new posts and save changes. Then re-check it and Save changes, that may give it the nudge it needs.
Good thought David but it didn’t make any difference.
It's a strange one... :-/
Aah ok - had a look at the function.
What happens if you add this to your Template:
<?php generate_do_comments_template('single'); ?>
Bob on David!
That worked! Perfect.
Thanks again.
Martin
Glad to be of help