Integrating with WordPress

I probably should be working on the 2.7 upgrade, but instead I started looking at photo gallery options other than Gallery2. It is just too slow. There is too much of it I don’t use as well. I think I have settled on zenphoto. It seems to work pretty well, with out the feature creep that Gallery2 has. I figured I would convert the annieandchris.net site to that.

It got me thinking though about how I might integrate it with WordPress. After seeing the tantan Flickr plugin, and how well it works, I figured that there must be a plugin for zenphoto. Well, no. Not really. There are a couple that will let you show pictures in the sidebar. And Trung’s presszen looked promising, but it didn’t seem to work. I started taking a look at the code for the tantan Flicker plugin, and saw how he was able to take control of a URI to insert his own code in with the current wordpress theme. I stripped out the relevant stuff, and got it to work. This is the code.

function parse_query(&$query) {
	$query->is_404 = false;
	$query->did_permalink = false;
}
function request($query_vars) {
    $query_vars['error'] = false;
    return $query_vars;
}

function cww_template() {
	get_header();
	echo '

Zen Integration

'; get_footer(); exit; } define("CWW_ZEN_BASEURL", "/blog/test"); if (strpos($_SERVER['REQUEST_URI'], CWW_ZEN_BASEURL) === 0) { status_header(200); remove_action('template_redirect', 'redirect_canonical'); add_filter('request', 'request'); add_action('parse_query', 'parse_query'); add_action('parse_request', 'parse_query'); add_action('template_redirect', 'cww_template'); } elseif (strpos($_SERVER['REQUEST_URI'].'/', CWW_ZEN_BASEURL) === 0) { header('location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'/'); exit; } ?>

I think that I may take a go at pulling in the zenphoto albums in a plugin, and see how it goes. I like how you create plugins in WordPress, and it is kind of fun poking around. It was frustrating for the longest time when I was trying to get it going, and I was getting the body of the blog showing up at the bottom. I finally realized that I needed to ‘exit’ the script to prevent the loop from happening. You would think you could override a WordPress function to prevent that instead.

3 thoughts on “Integrating with WordPress

  1. Hi,

    Can you kindly tell me how and where to put your code to integrate zenphoto in wordpress and get the desired results as per trung’s promissing plugin. An example page of integrated php code will he highly appritiated.

    Thanks and regards

  2. Sorry Khan, you must have misunderstood my post. I couldn’t get trung’s code to work either. That is why I started exploring creating something myself. But I don’t have anything right now other than the code above. It is no where near a plugin, and doesn’t do anything with zenphoto.

  3. Thanks for reply and am really don’t understand why Trung is not going to resolve that issue. Because I have firm believe that after resolving that issue he will be nominated for a noble prize to save un-countable numbers of brain cells to other fellow designers.

Comments are closed.