images posts

WordPress: Shortcodes

I’ve been playing with shortcodes in WordPress. They provide a nice way to allow the client to insert certain content without them needing to even deal with HTML, such as predefined pieces or wrappers with specific classes or structure. They are the only way to effectively run PHP functions from within a page without actually allowing PHP code to be run. This can allow pulling things from data, such as custom fields or from Pods CMS. The built in shortcode, for instance, pulls image data from the database about images connected to a post.

It’s very easy to add a shortcode. You create a function that does what you want and returns a string to output in place of the shortcode then use the add_shortcode() function of WordPress to attach it as a shortcode. The function is done like:

function repFunctionName($repArguments, $repContent=null){
    return "some string";
}

$repArgument is an array of arguments passed to the shortcode like:

[repShortcode repArgument1="value1" repArgument2="value2"]
Continue reading post "WordPress: Shortcodes"

Stearns: Slideshow, Media Tags

We wanted an image slideshow for our sidebar. I looked at some of the plugins available for doing this, but none looked to be exactly what we wanted, nor did they look very simple. I’ve worked with jQuery before with various image things, so I used it to build my own slideshow (building it in OO added to the development time, but it should be fairly versatile now). Then I had to get the appropriate images from WordPress to work with my javascript, which was quite a bit of work as well.

We want the images to easily be updatable by Stearns.  I don’t know why I was dead-set on having them be able to use the media library, but I was.  They could FTP files into a folder, which would be much easier for me.  But they might not even know how to do this, and letting them handle everything through the wordpress interface is preferable.  They’d have to crop and size them properly.  The images in the folder also wouldn’t have captions.  So I pressed on.

I thought perhaps I could have them update a gallery on a particular page, after having thought the gallery function wass very neat.  But it seems there is no way to add items from the media library to a gallery for a page (not in regular wordpress anyway) and I’m not sure that the “delete” link does what I want for removing items from the gallery (and I’m not willing to try).

Continue reading post "Stearns: Slideshow, Media Tags"