Reputation:
Here is a line of code that I want to comment out,
<h1 class="post_title"><a href="<?php the_permalink();?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
A popular way to comment it out would be to comment out the html and php separately.
<!-- <h1 class="post_title">
<a href="<?php // the_permalink();?>" title="<?php the_title_attribute(); ?>">
<?php // the_title(); ?></a>
</h1>
-->
Is there a better way to do this?
Upvotes: 2
Views: 852
Reputation: 1
If you want to print only the result from php functions. I hope this should help you.
<?
$var = //"<h1 class='post_title'><a href=".
"'php the_permalink()' ".
//" title=".
"'php the_title_attribute() ' ".
//">".
"'php the_title()' ".
//"' </a></h1>";
echo $var;
?>
or
<?
$var = /*"<h1 class='post_title'>.*/
/*"<a href='".*/"'php the_permalink()' "./*" title=".*/"'php the_title_attribute() ' "./*">".*/
"'php the_title()' ".
/*"</a>".
"</h1>"*/;
echo $var;
?>
Upvotes: 0
Reputation: 61
For that functionality you would have to refactor your code.
<?php
//print('<h1 class="post_title"><a href="'. the_permalink() . '" title="' . the_title_attribute() . '">' . the_title() . '</a></h1>');
?>
If all your code is within PHP then commenting out some of it becomes an easy thing, you would simply use PHP's commenting rules.
Upvotes: 0
Reputation: 2347
<!-- <h1 class="post_title">
<a href="<?php // the_permalink();?>" title="<?php the_title_attribute(); ?>">
<?php // the_title(); ?></a>
</h1>
-->
This will comments only HTML portion, where as you'll find rendered PHP code in view source of webpage..
better way..
<?php /* <h1 class="post_title">
<a href="<?php // the_permalink();?>" title="<?php //the_title_attribute(); ?>">
<?php // the_title(); ?></a>
</h1>
*/ ?>
Upvotes: 4
Reputation: 5633
There is the HTML way...
<!-- commented out stuff -->
...and there is the PHP way...
// for rows only
/* for
multiple
rows */
$or = /* for inline */ 'sections';
The difference between the 2 is that while the HTML way will still render the code on the page (can view using 'view source' in the browser), the PHP way will prevent it from being viewed by the outside world, ie. only you or other fellow programmers allowed to see the actual files will see the commented out pieces.
Upvotes: 0
Reputation: 2509
try this
<?php
/*
* <h1 class="post_title"><a href="<?php the_permalink();?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
*/
?>
Upvotes: 2