Need PHP version of wordpress shortcode function

I was reading iframes in WordPress and it was very helpful. However what I need to do is instead of always using a shortcode, sometimes I need to use it as PHP in one of the wordpress pages (ie. pages.php, index.php, etc..) How do I do that?

Add this to your functions.php file:

Read More
function add_iframe($atts) {
    extract(shortcode_atts(array(
    'src' => '/'
    ), $atts));
  $theframe = '<iframe src="'.$src.'" width="420" height="315" frameborder="0"></iframe>';
  return $theframe;
}
add_shortcode('iframe', 'add_iframe');

Usage:

Add [iframe src=any site here] to the content where you want the iframe to show.

What would be the PHP equivalent of this shortcode?

Related posts

Leave a Reply