Allow php in wordpress page -


i want use following code in wordpress. how can that?

<?php  $theme_name = get_template(); $directory = "wp-content/themes/" . $theme_name . "/pdf/ece340/"; $pdfs= glob($directory . "*.pdf"); foreach($pdfs $pdf) { $link= substr($pdf,48,90); ?> <a href="<?php echo $pdf; ?> "><?php echo $link; ?></a> <?php echo "\n\n"; echo "<br />"; } ?> 

below answer (taken here):

add_filter('widget_text','execute_php',100); function execute_php($html){      if(strpos($html,"<"."?php")!==false){           ob_start();           eval("?".">".$html);           $html=ob_get_contents();           ob_end_clean();      }      return $html; } 

copy above function @ end of functions.php file.

but best soluttion create custom template instead of using php in pages/widgets/posts. find more wordpress custom templates here.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -