Uncategorized

(Softly) Banging WordPress

I’ve not had nearly the desired time to monkey around in WordPress (hence the near stock template), but I am hoping over the more slow time of summer to slowly add and tinker and perhaps break. I am still trying to get my mind around the template/tag structure, which is fairly sensible.

What I’d really like is an ability to use PHP code in posts and templates, and I feel it is possible (I played this morning with the RunPHP plugin which seems more suitable for echo() type commands, where I prefer more code leverage.

My project was to convert the old “Where’s Alan” page that uses the slick IndyJuniour Flash mapper, XML in a complete PHP template I wrote in MovableType. I have a menu that allows me to pass a year as a script parameter, and thus pull up the XML file associated with that year.

I tried first creating it as a WP Page, but it never executed the PHP and I think there are issues with how parameters are passed to WP (everything actually funnels through the barebones index.php file). I threw my hands up in the air and just took the basic single entry layout created it as a new *.php file in my main blog directory, and we are fairly good to go as a direct URL:
http://cogdogblog.com/indy.php

Then I tried to get fancy and find away to re-direct it as a WP page, so eventually it can be integrated into what should expand as a side bar navigation scheme. What I was able to see by having my page merely use PHP to echo the $SERVER['QUERY_STRING'] is that I could detect this page by a value of pagename=indyjunior, which is what is passed when you click on a page link. So I then hacked the opening of the wp-blog-header.php page to sniff first for this value, and divert from there:

// alan's hack for trapping my special pages
if ($_GET['pagename'] == 'indyjunior') header('Location:/cdb/indy.php');

All it means is that a link to:
http://cogdogblog.com/indyjunior/

silently bops you to the real page:
http://cogdogblog.com/indy.php

I am sure there is a more elegant way about this, but this is all part of the learning cliff.

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Comments

  1. That’s what the “softly” was for! Should have been “gently”? “Lovingly”? Anyhow, great piece on bad McChoice of McWords.

Comments are closed.