Title: Basic PHP help needed
Last modified: March 1, 2018

---

# Basic PHP help needed

 *  Resolved [cyber-ki](https://wordpress.org/support/users/cyber-ki/)
 * (@cyber-ki)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/basic-php-help-needed/)
 * Hi I have a question and I hope someone can help me.
    I use the twenty seventeen
   theme and I want to edit the comments. I managed to achieve what I wanted however
   a small bit of the php does not feel right. I do not know php and even though
   it works fine now, I want to do it the proper way. This is the part I’m talking
   about:
 *     ```
       <?php
       	endif; 
       ?>
       ```
   
 * I tried several ways but this is the only way I got it to function properly
    
   Is there anyone that can tell me how to write this in a prober way? This is the
   original code:
 *     ```
       	endif; // Check for have_comments().
   
       	// If comments are closed and there are comments, let's leave a little note, shall we?
       	if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
   
       		<p class="no-comments"><?php _e( 'Comments are closed.', 'twentyseventeen' ); ?></p>
       	<?php
       	endif;
   
       	comment_form();
       	?>
   
       </div><!-- #comments -->
       ```
   
 * And this is the the code how it’s now (after I edited).
 *     ```
       	endif; // Check for have_comments().
       // If comments are closed and there are comments, let's leave a little note, shall we?
       	if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
   
       		<p class="no-comments"><?php _e( 'Comments are closed.', 'twentyseventeen' ); ?></p>
       	<?php
       	endif; 
       ?>
       		<div class="hidecform"> 
       		<input type="checkbox" id="toggle">
       		<label for="toggle" class="toggle" onclick=""></label>  
   
       <?php comment_form(); ?></div>
   
       </div><!-- #comments -->
       ```
   
 * Thanks for taking the time to read and I really appreciate your help

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/basic-php-help-needed/#post-10027437)
 * Your code is already quite good, there would be no problems if you left it as
   it is, I would expect that anyone in the future who had to read and modify this
   code would be able to follow it.
    This is what I would change it to if it had
   to exist in my perfect world:
 *     ```
       	endif; // Check for have_comments().
       // If comments are closed and there are comments, let's leave a little note, shall we?
       	if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) {
       		echo '<p class="no-comments">' . _e( 'Comments are closed.', 'twentyseventeen' ) . '</p>';
       	}
       ?>
       	<div class="hidecform"> 
       	<input type="checkbox" id="toggle">
       	<label for="toggle" class="toggle" onclick=""></label>  
       <?php comment_form(); ?>
       	</div>
       </div><!-- #comments -->
       ```
   
 *  Thread Starter [cyber-ki](https://wordpress.org/support/users/cyber-ki/)
 * (@cyber-ki)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/basic-php-help-needed/#post-10027521)
 * Great! RossMitchell
 *     ```
       	<?php
       	endif; 
       ?>
       ```
   
 * On its own ^ felt a bit empty and useless 😉
 * Thanks a million!
 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/basic-php-help-needed/#post-10028042)
 * Not at all, it works perfectly. Just in my opinion a little verbose.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Basic PHP help needed’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/basic-php-help-needed/#post-10028042)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
