Advertise on Site! You can Advertise on our site. Find out More

how to insert the php code in wordpress post

5 Flares Twitter 4 Facebook 1 Google+ 0 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 5 Flares ×

Some time we need to execute and use the php code in wordpress post and page. There is solution for inserting the php code in to wordpress post.

I found very useful wordpress plugin for that. But my advise is don’t use this plugin ever try to put your php code as possible in wordpress theme.

Exec-PHP

The Exec-PHP plugin executes PHP code in posts, pages and text widgets.

Features:

  • Executes PHP code in the excerpt and the content portion of your posts and pages
  • Configurable execution of PHP code in text widgets (for WordPress 2.2 or higher)
  • Write PHP code in familiar syntax, eg. <?php ... ?>
  • Works in your newsfeeds
  • Information about which users are allowed to execute PHP with the current security settings (for WordPress 2.1 or higher)
  • Configurable user warnings for inappropriate blog and user settings (for WordPress 2.1 or higher)
  • Restrict execution of PHP code in posts and pages to certain users by using roles and capabilities
  • Update notifications through the ‘Plugins’ menu in WordPress if a new version of the Exec-PHP plugin is available (for WordPress 2.3 or higher)
  • Internationalization support (english and german included, many more available)
  • Comes with documentation

Inline PHP

The plugin can execute php string in posts/pages, and display the output as the contents of posts/pages. Just quote what you want to execute in <exec>...</exec> or [exec]...[/exec] tag.

You can put the php code in post following way.

<exec>
       $filestr = file_get_contents('http://www.seocompany.ca/pagerank/page-rank-update-list.html');
       if (preg_match('/<p>.*<\/p>/ums', $filestr, $matches)){
           echo str_replace("<p><a href=\"#page-rank-update-list-history\">Top of Page Rank Update List History</a></p>", "", str_replace("<table width=\"65%\">", "<table width=\"100%\">", $matches[0]));
       }
   </exec>
5 Flares Twitter 4 Facebook 1 Google+ 0 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 5 Flares ×
  • http://www.phptrainingchandigarh.com/ PHP Training Chandigarh

    Awesome post! It really helped me a lot! Thanks for sharing it.

  • Pingback: how to insert the php code in wordpress post « digcms

  • http://quitmoking.blogspot.com/ Leo Blesofsky

    Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.

  • http://www.ppttemplate.org ppt template

    great post.. really helpd me

  • http://payperclicksadvertising.info Venessa Listen

    Great read. Thanks for the info!

  • http://tourfurther.com Williams Feusier

    I’ve just started off a blog, the knowledge you give on this site has aided me extremely. Thank you for all your time & work.

  • http://colleges-withphysicaltherapymajors.blogspot.com/ Claud Smale

    Of course, what a great site and informative posts, I will add backlink – bookmark this site? Regards, Reader

  • http://symptomsanxiety.info Matilde Ysaguirre

    This post makes a lot of sense !

  • http://uautocity.info Ileana Juenemann

    Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.

  • http://collegefor-physicaltherapy.blogspot.com/ Corliss Orsak

    I’ve just started off a blog, the knowledge you give on this site has aided me extremely. Thank you for all your time & work.

5 Flares Twitter 4 Facebook 1 Google+ 0 StumbleUpon 0 LinkedIn 0 Buffer 0 Filament.io 5 Flares ×