Add this to the functions.php in your theme folder to enable the comments. You probably need to tick a box on the store page under ‘Discussion’ -> ‘Allow comments’.
add_filter( 'wpsl_post_type_args', 'custom_post_type_args' );
function custom_post_type_args( $args ) {
$args['supports'] = array( 'title', 'editor', 'author', 'excerpt', 'revisions', 'thumbnail', 'comments' );
return $args;
}
Create a template for the wpsl_stores custom post types.
So you create a file called ‘single_wpsl-stores.php’, and the best way to get started with this is to open the ‘single.php’ from your theme folder. Copy the content and place it in the ‘single_wpsl-stores.php’ file.
You probably see this:
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<?php endwhile; // end of the loop. ?>
Remove it and replace it with this:
<?php
echo do_shortcode( '[wpsl_map]' );
echo do_shortcode( '[wpsl_address]' );
?>
<?php comments_template( '', true ); ?>
This will show the map, address and underneath it the comments form.
Hi Tijmen,
Many thanks for your code 🙂
I use for example the Twenty Fourteen theme.
I added all codes into functions.php (in the theme dir) and created the single_wpsl-stores.php based on the single.php with your additions, and put that file in the same dir as single.php.
The problem is that when I edit or add a new shop, no option is available for checking a box ‘Discussion’ -> ‘Allow comments’ (like in normal blog or page posts).
Also in the header drop-down menu (screen properties) the comment option is not available.
Need I add the add_filter function in the functions.php between specific lines? Now, I just copied the code at the end of this file..
Can you check if the comments are enabled on your site on the WP Settings -> Discussion page?
Jup, it is enabled.
I’m able to post comments in general posts and pages.
Also, per general post or page I’m able to enable/disable comments in the admin area.
Can you send me an email at info at tijmensmit.com?