Reputation: 2920
This is a default code in Wordpress which I want to get rid of but don't necessarily want to fully delete forever:
<?php if ( is_active_sidebar( 'sidebar' ) ) : ?>
<div class="sidebar fright" role="complementary">
<?php dynamic_sidebar( 'sidebar' ); ?>
</div><!-- .sidebar -->
<?php else : ?>
<div class="sidebar fright" role="complementary">
<div id="search" class="widget widget_search">
<div class="widget-content">
<?php get_search_form(); ?>
</div>
</div><!-- .widget_search -->
<div class="widget widget_recent_entries">
<div class="widget-content">
<h3 class="widget-title"><?php _e("Latest posts", "baskerville") ?></h3>
<ul>
<?php
$args = array( 'numberposts' => '5', 'post_status' => 'publish' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
echo '<li><a href="' . get_permalink( $recent["ID"]) . '" title="' . esc_attr( $recent["post_title"]).'" >' . $recent["post_title"] . '</a></li>';
}
?>
</ul>
</div>
<div class="clear"></div>
</div><!-- .widget_recent_entries -->
<div class="widget widget_text">
<div class="widget-content">
<h3 class="widget-title"><?php _e( "Text widget", "baskerville" ); ?></h3>
</div>
<div class="clear"></div>
</div><!-- .widget_recent_entries -->
</div><!-- .sidebar -->
<?php endif; ?>
How do I comment out the entire code? If I simply do < folowed by !-- at the very beginning and --> at the end it doesn't work.
Upvotes: 0
Views: 645
Reputation: 161
If you want to be mega hacky, just change below lines
<?php if ( is_active_sidebar( 'sidebar' ) ) : ?>
becomes
<?php if ( is_active_sidebar( 'something_youre_never_ever_going_to_call_a_sidebar' ) ) : ?>
This means this whole section of code will never get hit!
Upvotes: 1
Reputation: 3237
Standard PHP commenting syntax is:
// comment
for one-liners
/* multiple lines of code */
for multiple lines
Be aware that you may encounter some erratic behaviour if you have a mix of PHP and pure HTML not enclosed within PHP tags as /* blah */
will inhibit the PHP interpreter from doing its work with the code that's actually enclosed in PHP tags but will not comment out pure HTML, which the snip of code you wish to leave out does have
Upvotes: 2