-1

Need to call this php function inside a modal window from sidebar text widget

<?php echo get_post_meta( $post->ID, 'link', true ); ?>
0

There are several examples on the net, however I use this:

<?php

//functions.php

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

?>
  • Oh great, can you give me the exact code for the above one. I mean <?php echo get_post_meta( $post->ID, 'link', true ); ?> sorry im a begineer. – Praveen M Aug 20 '13 at 17:17
  • You can use it as it is : ), you need to copy the snippet to your functions.php – iEmanuele Aug 20 '13 at 17:19
  • Oh ok,,you mean i need to copy that code to functions.php and then call the php function in text widget right? – Praveen M Aug 20 '13 at 17:20
  • Yes you're right – iEmanuele Aug 20 '13 at 17:21
  • Does the code work ? – iEmanuele Aug 20 '13 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.