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.
how to insert php code in 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.
$filestr = file_get_contents('http://www.seocompany.ca/pagerank/page-rank-update-list.html'); if (preg_match('/</pre> .*<\/p>/ums', $filestr, $matches)){ echo str_replace(" <a href="\"#page-rank-update-list-history\"">Top of Page Rank Update List History</a> <pre>", "", str_replace("", "", $matches[0])); }
great post.. really helpd me