It is simple to install and use Allow PHP in Posts and Pages Plugin.
It also allows you to save frequently used bits of code in the form of snippets to be used across various pages. With the use of this plugin, WordPress tags automatically disable and and you are allowed to add your tags with the BBcode items such as and. Using “Allow PHP in Posts and Pages” WordPress Plugin you can add the PHP code to the HTML post editor and run the PHP codes which were earlier blocked due to non-recognition of PHP programming code.īy adding a shortcode, your code “Allow PHP in Posts and Pages” Plugin includes PHP in the WordPress post and pages. The plugin provides a shortcode and options page so that the code can be added to the admin options page and then output in the posts using shortcodes. The Insert PHP Code Snippet Plugin enables you to add your PHP code to WordPress posts and pages without the need for custom templates. You can install Insert PHP from the WordPress Dashboard, or you can upload it to the plugins directory. You simply have to paste the PHP Code into the post or page and then replace in the PHP Code with and. The plugin code is short for quick loading and running. Using this plugin, you can do pretty much that PHP can do when it is embedded in the PHP Templates. The Insert PHP Plugin enables you to run PHP Code in WordPress Posts and Pages. Using Plugins to run PHP Code inside WordPress Posts or Pages Insert PHP Plugin It will execute the code in the custom function.Īs for this example, it simply lists all the pages on the site. Taking the above example, the name of the shortcode is “output_pages.” Now, open any WordPress post in the editor and type the name of the shortcode using square brackets such as. When you save the functions.php file, the shortcode has been created. This will enable to execute the PHP within the function that you have created. The second parameter is “list_pages_function” which directs WordPress to perform the contents of this custom function when it finds the particular shortcode. You can see that the first parameter of the add_shortcode function is “output_pages”. Here, you should note that a shortcode has been created by the name “output_pages”. Return wp_list_pages(‘sort_column=menu_order’) Īdd_shortcode (‘output_pages’, ‘list_pages_function’) Now, open the functions.php file and paste the following code before the closing ?> PHP Tag. To illustrate this method, I will be building the custom shortcode for outputting a complete list of existing WordPress pages.įor this, the PHP function is – “wp_list_pages ()”. Here, I am going to illustrate both of these methods so that you can easily insert PHP Code in a WordPress Post. Secondly, you can use Plugins which enable you to use PHP within WordPress posts and pages. Well, you have as much as two methods of running any kind of custom PHP Code within WordPress posts and pages.įirstly, you can build a shortcode for running PHP Code by inserting it into the post content.