4

I want to comment out the whole code below. What would be the easiest way to do it without using multiple comments? Thanks in advance.

<nav id="site-navigation" class="main-navigation" role="navigation">
    <h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
    <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
    <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->
  • 1
    You can't comment them both out. I mean, you can comment out the results from the PHP, but the commands would still run. You'd need to comment out the PHP and then the HTML separately in order to keep the PHP from running. – crush Jun 03 '13 at 19:55
  • use the `/* ... */` multi-line comment style? – Marc B Jun 03 '13 at 19:55
  • 1
    @MarcB That's not a comment in HTML – crush Jun 03 '13 at 19:56
  • @crush: OP isn't exactly clear on WHAT they want to comment out. html only? html+php? php only? – Marc B Jun 03 '13 at 19:57
  • @MarcB He wants to comment out both with a single comment. Apparently it is doable with ` – crush Jun 03 '13 at 19:58
  • I want to comment out the whole code. I could have done separate commenting for both but it would take a lot of time so I asked if someone knows anything better. –  Jun 03 '13 at 19:59

2 Answers2

7

just surround the entire block with php comments like this:

<?php /*
<nav id="site-navigation" class="main-navigation" role="navigation">
    <h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
    <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
    <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->
*/?>
Fisch
  • 3,775
  • 1
  • 27
  • 38
  • This is the answer apparently, but it comes from the link that Flaxbeard posted below...this question is a duplicate. – crush Jun 03 '13 at 20:02
2
<!-- <nav id="site-navigation" class="main-navigation" role="navigation">
<h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav> -->

Should suffice. They are multiline comments.

This should help: https://stackoverflow.com/questions/5781375/comment-out-html-and-php-together

Community
  • 1
  • 1
Flaxbeard
  • 501
  • 1
  • 5
  • 16