Hide Comment on Single Event Listing Page

Hide Comment on Single Event Listing Page

A user of WP Event Manager can display or hide the comment section on the single event listing page. In this guide, you will learn about how you can disable or hide the comment section on your single event listing page.

Here are the steps you need to take to perform the task:

Open your child theme,
Add the following code into the funtions.php file.
  1. function wpem_comment_disable( $open, $post_id )
  2. {
  3.     $post_type = get_post_type( $post_id );
  4.      if ( $post_type == 'event_listing' ) {
  5.         return false;
  6.     }
  7.     return true;
  8. }
  9. add_filter( 'comments_open', 'wpem_comment_disable', 10 , 2 );

  10. Find a single.php file in the parent theme directory & duplicate it in the child theme.

    Find comments_template() function in single.php.

    There should be the following code:

  11. if (comments_open() || get_comments_number()) :
  12.      if ('event_listing' !== get_post_type()) :
  13.          comments_template();
  14.      endif;
  15. endif;
      Save


    • Related Articles

    • How to allow comment forms on each event?

      In order to enable a comment form on the single event page, please add the following code in the functions.php file: add_filter( 'event_manager_allowed_comment', 'YOUR_THEME_allowed_comment', 10 ); function YOUR_THEME_allowed_comment($status) { ...
    • Event Detail Page

      The Event detail page carries various details of a particular event. These details include the event title, event type, event location, event start date & time, event end date & time, event description, etc. besides this, you can also get the details ...
    • How to display additional custom fields on a single event page?

      This WP Event Manager tutorial shows you how you can add the custom event fields to a single event page. It requires customizing your PHP file. Display additional custom fields on a single event page To display additional custom fields on a single ...
    • Hide Additional Information Section from Single Event Page

      Different businesses have different requirements and custom fields help them adjust single event listing fields as per their requirements. WP Event Manager offers a separate section in the single event listing page named Additional fields that ...
    • Create single event template with Elementor Pro

      Elementor Pro is the advanced and paid version of the Elementor plugin. It enables users to access premium features for developing a web page template. One needs to follow the below-mentioned steps to develop a dynamic single event template on ...