Can I Run My Own PHP Scripts Within Joomla or WordPress Pages?

Jim Dee
Jim Dee
Aug 11, 2017 · 3 min read
“A macro shot of a Macbook Pro screen with a few dozen lines of code” by Luca Bravo on Unsplash

This is a common question, actually — and the answer is an enthusiastic Yes!

→ For WordPress, check out the “Insert PHP” plugin.

→ For Joomla, check out the “Jumi” extension.

I prefer working in Joomla myself, so here are some notes about using Jumi:

While Jumi has quite a lot of functionality, the easiest way to use it (IMHO) is to basically “include” your custom PHP script by using their syntax. In the article or module where you want your script to run, you would just need to call the PHP script, like so:

{jumi [path to your script]}// For example, if you keep your scripts at
// yoursite.com / programs
// and your script is called "go.pph"
// then the code you would put in your article
// or module would look like this:
{jumi [programs/go.php]}

So, in the above second example, it assumes that you have a file called “go.php” that lives at [root] / programs. You may want to locate your scripts elsewhere, of course. Just adjust the path accordingly.

From there, the script will run just the same as if it were on any other web site. Super easy!!

Passing Variables to Your Scripts

There are two ways to do send value to your PHP scripts when using Jumi. The first is via normal URL GETs and POSTs. I find an easy way to do this is to setup a Joomla article on a hidden menu. For example, start a new article on your site, and make a hidden menu, and add that article to it with the alias “widgets”. Thus, you would now be able to view that article at the address: www.mysite.com/widgets. From there, you simply pass along values as usual, such as this GET:

mysite.com/widgets?id=123

Then, in your PHP, you just do something like:

$thisWidget = $_GET['id'];

… and then you run your script passing $thisWidget to your SQL. (Of course, you would want to properly validate such a thing, as always.) As noted, you can $_POST data to your scripts as usual, too.

(Of course, if you’re working in a Joomla context, you can leverage JInput to better receive your variables. But, that’s a whole different conversation.)

A Second Method

You can also send values to your script another way. In your include script, you can insert additional arguments after the script declaration. For example:

{jumi [path/to/script/script.php][bob][mary]}

Jumi saves the arguments you send along in an array called $jumi. So, above we have sent “bob” and “mary”. Thus, in your PHP, you would grab those like this:

$person01 = $jumi[0]; // that would be bob$person01 = $jumi[1]; // that would be mary

I admit this part isn’t the most intuitive because you’re locked into a specific indexing there for that $jumi array! But, it does work. I usually use the previously mentioned method of passing along values via GETs and POSTs. But, sometimes it’s handy or necessary to do this the second way.


✍🏻 Jim Dee maintains his personal blog, “Hawthorne Crow,” and a web design blog, “Web Designer | Web Developer Magazine.” He also contributes to various Medium.com publications. Find him at JPDbooks.com, his Amazon Author page, Facebook, Twitter, Instagram, LinkedIn, Medium, or via email at Jim [at] ArrayWebDevelopment.com. His latest novel, CHROO, is available on Amazon.com. If you enjoy humorous literary tales, please grab a copy!

Web Designer / Web Developer Magazine

WDWD Magazine features articles on web site design / development, internet marketing, social media, SEO, and topics like marketing, communications, business development, etc. Editor: Jim Dee of Array Web Development — jim@arraywebdevelopment.com.

Jim Dee

Written by

Jim Dee

Web guy at ArrayWebDevelopment.com; author of books & blogs. See: JPDbooks.com.

Web Designer / Web Developer Magazine

WDWD Magazine features articles on web site design / development, internet marketing, social media, SEO, and topics like marketing, communications, business development, etc. Editor: Jim Dee of Array Web Development — jim@arraywebdevelopment.com.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade