Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In a WordPress blogsite, I'd like to add additional functionality but write it something other than PHP if possible, Python for example. For example, I'd like to create a self-scheduling page for a business so that clients can choose appointment times, and then write an admin side for the business to view and manage the bookings. Of course all I really care about from WP for this sub-area is the header/footer and menu links presented on the customer-facing pages.

I can imagine a scheme such as creating Pages that contain nothing more than a div and a bit of Javascript to fill the div with content from a Python-backed page, but don't have a good feel for whether this is a good idea.

I guess my question is whether there's a good way to use WordPress for the general page layout but use something other than PHP for the content area?

share|improve this question
    
For what it's worth, I just went ahead and learned enough PHP to accomplish the particular task directly. But I appreciate the knowledge about different options because other projects may have other needs. –  jfklein Dec 15 '11 at 0:12

3 Answers 3

up vote 5 down vote accepted

You've got a couple of options here, but they're all pretty hacky ...

iFrame

The easiest way would be to script your external application in whatever language you want and embed it in a typical WordPress page using an iFrame.

Applet

Java, Flash, Air, and Silverlight are all objects embedded directly into HTML pages. If your external application were using one of these technologies, you could easily embed the object on a standard WordPress page.

A better way ...

I'm not going to ask why you don't want to use PHP, because that's not really the point here. But what you could do is script an external application and expose an API. Then you can have WordPress interface directly with the API and use PHP to display all of the content.

I recommend this because you're no longer merely embedding an application inside a page, but actually tying the application together with WordPress. I've actually seen people tie WP together with Python scripts running on the server, so it is possible.

It's more a question of what exactly you're trying to accomplish, what technologies you plan to use, and you relative skill with each.

share|improve this answer

I'd go with a custom template page and an iframe. This would be the easiest solution.

share|improve this answer

One way this can be done non-invasively is by using custom fields. General idea is that your external program writes output to a custom post meta field, and then WP theme reads it with get_post_meta().

Alternatively, you can accomplish this without altering your theme. I wrote a plugin that lets you include a custom meta field inside any post - and - a small bash script (well, php-CLI) that takes STDIN and stores it as custom meta.

Plugin: http://pp19dd.com/wordpress-plugin-include-custom-field/

So, for example, you could put this in a cron entry:

python /home/programs/blarg.py -some -option | /var/www/html/wordpress/wordpress-meta.php "My Python Program Part 1"

And inside post / page that needs that displayed, just put [include "My Python Program Part 1"]

  • Note: You can even include content of custom fields in plain text widgets, if you edit your theme's functions.php and add: add_filter('widget_text', 'do_shortcode');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.