Converting a page template to a plugin
I have decided to stop using the NextGen gallery plugin – basically because the code has bloated from 1Mb to 9Mb with features I don’t want (as it was when Alex Rabe maintained it, I only used the basic image management). It was rather forced upon me as when I tried to follow the instructions to wind back to the pre-version 2, it broke the site and I lost all the image information.
So I have decided to use WordPress’ media management (which was inexistant when I started using NextGen). I’ve found a plugin to deal with the thumbnail cropping (because what’s on offer is useless) and now I’m working on creating a way of presenting the images.
I’ve looked at various “portfolio” plugins, but none of them actually offer a solution for what I need – they are oriented towards graphics people or photographers and I’m looking for a way of presenting my work as a visual artist.
Bearing in mind Justin Tadlock’s advice to put personal “permanent” customisations into a plugin rather than changing functions.php every time you change or modiy your theme, I’m trying to do this with my galleries.
My solution at the moment is a custom page template, but it would be better if the gallery could be called with a shortcode
I use the content on the page to give an introduction to the works that are being shown and this needs to be integrated into the gallery structure –
schematically the existing custom template looks like this :
< Query to get the attached images > < Do things > < the_content() --intro to work > < do the rest >
This works. But trying to get to the shortcode solution has defeated me. I need to stop the_content() from printing as is usual, and I need it’s output as a variable.
I’ve found that I can get something using
$post->post_contentbut it starts, inevitably with “[workgallery]…” my shortcode, which I don’t know how to get rid of and equally inevitably, the_content() outputs below as well.
I trawled the net, and found that I could put the_content() into an output buffer, which would give me it’s output as a variable but as the content of the page contains my shortcode, it sets up an infinite loop and the page goes into meltdown.
I’ve looked at
add_filter(the_content, $myvariable)but all the examples I’ve found have been for adding bits to a post, rather than manipulating the output as described above.
Advice and possible solutions would be much appreciated.
- The topic ‘Converting a page template to a plugin’ is closed to new replies.