Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

Enable Comments for Standalone

To enable comments add the following code to a new file at wp-content/plugins/envira-standalone-enable-comments.php and activate it in your Plugins screen:

<?php
/**
* Plugin Name: Envira Gallery - Enable Comments
* Plugin URI: https://enviragallery.com
* Version: 1.0.0
* Author: Envira Gallery Team
* Author URI: https://enviragallery.com
* Description: Enables comments for Envira CPT
*/
/**
* Enable comments on Envira Galleries
*
* @since 1.0.0
*
* @param 	array 	$post_args 	Post Type Arguments
* @return 	array 				Post Type Arguments
*/
function envira_standalone_enable_comments( $post_args ) {
	
	$post_args['supports'][] = 'comments';
	return $post_args;
}
add_filter( 'envira_gallery_post_type_args', 'envira_standalone_enable_comments' );
/**
* Don't remove the Discussion Metabox in edit screens
*
* @since 1.0.0
*
* @param 	array 	$ids 	Metabox IDs to include in Envira edit screens
* @return 	array 			Metabox IDs to include in Envira edit screens
*/
function envira_standalone_comments_metabox( $ids ) {
	$ids[] = 'commentstatusdiv';
	return $ids;
}
add_filter( 'envira_gallery_metabox_ids', 'envira_standalone_comments_metabox' );

You’ll now have the option to enable comments for your galleries in the Screen Options panel by enabling the Discussions option:

In the gallery edit screen, enable the Discussion option.