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 ...
    • 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 ...
    • Event listings not showing up in the [events] page

      The most common reason behind this particular issue is an error in the Java Script as events are loaded through Ajax. To debug the Javascript error when the event listings are not displayed, you need to pass through the following steps: Go to your ...
    • Event listings throw 404 page error

      Users may come across the 404 error while accessing the event listings. In this article, we will tell you how you can solve this issue. Here are the steps you need to take to solve this issue: Make sure that it is not a permalink issue: Go to your ...