Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #23624

    Sascha L
    Participant

    Hi dear support!

    First let me tell you that I love your theme. X is really amazing!

    Could you please tell me how it is possible to disable the comment section on pages?

    http://golf-duda.de/impressum/ (Password: simsum666)

    http://golf-duda.de/datenschutzerklaerung/

    Your help is really apreciated 🙂

    Cheers
    Sascha

    #23787

    Christian
    Moderator

    Hey Sascha,

    Thank you for your kind words.

    You might find this tutorial helpful.

    Or, you can copy the code below in your functions.php file if you want to disable it sitewide.

    // Disable support for comments and trackbacks in post types
    function df_disable_comments_post_types_support() {
    	$post_types = get_post_types();
    	foreach ($post_types as $post_type) {
    		if(post_type_supports($post_type, 'comments')) {
    			remove_post_type_support($post_type, 'comments');
    			remove_post_type_support($post_type, 'trackbacks');
    		}
    	}
    }
    add_action('admin_init', 'df_disable_comments_post_types_support');
    
    // Close comments on the front-end
    function df_disable_comments_status() {
    	return false;
    }
    add_filter('comments_open', 'df_disable_comments_status', 20, 2);
    add_filter('pings_open', 'df_disable_comments_status', 20, 2);
    
    // Hide existing comments
    function df_disable_comments_hide_existing_comments($comments) {
    	$comments = array();
    	return $comments;
    }
    add_filter('comments_array', 'df_disable_comments_hide_existing_comments', 10, 2);
    
    // Remove comments page in menu
    function df_disable_comments_admin_menu() {
    	remove_menu_page('edit-comments.php');
    }
    add_action('admin_menu', 'df_disable_comments_admin_menu');
    
    // Redirect any user trying to access comments page
    function df_disable_comments_admin_menu_redirect() {
    	global $pagenow;
    	if ($pagenow === 'edit-comments.php') {
    		wp_redirect(admin_url()); exit;
    	}
    }
    add_action('admin_init', 'df_disable_comments_admin_menu_redirect');
    
    // Remove comments metabox from dashboard
    function df_disable_comments_dashboard() {
    	remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
    }
    add_action('admin_init', 'df_disable_comments_dashboard');
    
    // Remove comments links from admin bar
    function df_disable_comments_admin_bar() {
    	if (is_admin_bar_showing()) {
    		remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
    	}
    }
    add_action('init', 'df_disable_comments_admin_bar');
    

    Hope that helps. 🙂

    #23892

    Sascha L
    Participant

    Oh yes thank you very much!

    #24125

    Christian
    Moderator

    You’re welcome.

    #97681

    LucyKeile
    Participant

    Hey support team! I am trying to accomplish the same. I understand what you have told Sasha, I found the function php file, but I do not know where to paste the code above. I don’t want to mess it up. I do want to remove all comment function though.

    Thank you!

    Lucy

    #97700

    LucyKeile
    Participant

    I watched the tutorial and made the correct changes. Thnx

    #97750

    Mrinal
    Member

    Hi Lucy,

    You should placed them into functions.php file of your child theme, learn more about child theme here: http://theme.co/x/member/kb/how-to-setup-child-themes/

    You can use a plugin instead of any codes if you feel uncomfortable with code changes, the plugin is: http://wordpress.org/plugins/disable-comments/

    #122591

    Ruben A
    Participant

    Thank you, For the video upload. This knowledge base has been very helpful.

    #122794

    Rubin
    Keymaster

    You’re welcome!

    #143583

    kmarois
    Participant

    Just wanted to add, when I tried doing this through the wordpress editor I got a 500 Internal Server Error everytime. My workaround was to edit the file locally then upload directly to the child theme folder.

    #143976

    Christian
    Moderator

    Thanks for sharing the workaround Kmarois. 🙂

    #285104

    Tech4Eleven
    Participant

    there really should be a way to disable comments on pages that built into X theme.

    #285521

    Lely
    Moderator

    Hello There,

    We certainly appreciate the feedback! This is something we can add to our list of feature requests. This way it can be taken into consideration for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive. Thanks!

    #288469

    Henry S
    Participant
    This reply has been marked as private.
    #288790

    Thai
    Moderator

    Hi Henry,

    Thank you for writing in! Please enable your wp_debug. To do this open the wp-config.php file on the root directory of WordPress installation, find the:

    define('WP_DEBUG', false);

    and update it to

    define('WP_DEBUG', true);

    Let us know the error the site is displaying, also provide us login credentials (Admin and FTP) in private reply so we can take a closer look.

    Cheers!