How do I comment out multiple lines with HTML and PHP code in it?
40,864
Solution 1
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 -->
*/?>
Solution 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
Author by
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
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 -->
-
crush almost 11 yearsThe PHP commands would still run.
-
crush almost 11 yearsYour link shows that this question is a duplicate.
-
crush almost 11 yearsThis is the answer apparently, but it comes from the link that Flaxbeard posted below...this question is a duplicate.
-
Admin almost 11 yearsWow. Good one. Thanks