Using A Custom Field In WordPress – An Example

custom fields screenshot

Custom fields in WordPress seemed like an elusive topic. For quite a while, whenever I needed to include something in my theme that didn’t have a place within the WordPress admin interface, I would hard code variables into the PHP. That was entirely more work that was necessary. I finally realized the simplicity and power of custom fields. I thought I’d share my most recent use of a custom field with the thought that a simple example may make it easier for the next guy.

My theme was to be used for a blog involving a large number of authors and I wanted to include the author’s name in the same place within the theme for each post. Here’s the part I added to the theme where I wanted to display the author’s name. (within PHP tags of course)

$key="Post_Author";
$myauthor = get_post_meta($post->ID, $key, true);
if (!empty($myauthor)) {
  echo "
by ".$myauthor."
"; }

After you’ve added something like this to your theme, just go to your new post and add a custom field with the name that you put here that is fed into the $key variable. Then enter a name for the post’s author.
I’ve added a css class to the div so we can style it to fit the theme.

All of this can be altered to fit other uses of course. If you’d rather use the field to display the name of a song that inspired your post, or the book you’re currently reading, just change the name in the custom field on your post and in your theme, change the “Post_Author” to whatever name you chose for your field.

I am aware that for blogs with more than one user, the post author field will be available to select the posts author from the list of users. That’s great but makes a far less useful example of how to use custom fields.

Posted in Wordpress | Tagged , , | Leave a comment

Adding A Zenphoto Gallery To Your WordPress

I tend to be a very trigger happy photographer. Whether it is with my own Canon point-and-shoot or with my sister’s borrowed Nikon D100, I love taking a lot of pictures. I also like to share those on the web. I started getting into Flickr sharing but quickly discovered that I wanted to share more images than I was able to on their free service. As a designer and operator of some of my own web sites, I found it more cost effective to host the images myself but desired the simplicity and functionality of a service like Flickr. That’s when I came across Zenphoto.

Zenphoto is a database driven application written in PHP that is built with a clean and customizable backend for managing photo galleries on a web site. Zenphoto allows you to upload images directly from the web interface as well as by FTP. It also is easily customized with themes available to change the public facing side of the gallery. I have built a few different nice looking themes for Zenphoto but until recently, when a visitor to my blog chose to look at my gallery, they would invariably feel as though they transitioned to another web site as the Zenphoto gallery was never a perfect match for the blog.

Finally, I have integrated Zenphoto into my WordPress blog. I have already been enjoying the integration and have plans for many other improvements with how they work together, but I thought I’d share what I’ve done thus far for anyone interested.

My ZenPhoto Gallery

Here is where I got the files and a place to start from. He does a very good job simplifying things.  http://tech.einaregilsson.com/2007/08/06/integrating-zenphoto-into-wordpress/

To follow some of this, a little understanding of PHP may be required.

Copy the wordpress-integration-zp-theme folder into your zenphoto/themes folder and then in Zenphoto choose Options and activate the theme called ‘WordPress Integration Theme’.

Copy the files (zp-index.php, zp-image.php, zp-album.php, zp-style.css) from the wordpress-theme-files folder into your current WordPress theme folder, /wp-content/themes/yourthemename. You’ll see the files now when you go to edit your theme from within WordPress.

Your installation of Zenphoto should be within the WordPress folder on your server. ( yoursite.com/zenphoto/ ) When you get the zen-integration.php file from the link I listed above, put it in the plugins folder and activated it in WordPress, it will install a link to your Zenphoto into the management panel. From this point, some PHP and template alterations will be required from your WordPress theme editor to make it look the way you want it to. Basically, at this point, Zenphoto should be displaying in the content area on your photo page.

To this point I haven’t completely integrated the Zenphoto management into the WordPress template so when you use the link to the Zenphoto management console, you essentially leave WordPress. So to improve flow, I added a link back to the WordPress management page.

To do this, you just have to create the link in zp-core/admin-functions.php. In the function printLogoAndLinks(), I inserted “| &nbsp; <a href=\”/wp-admin/\”>”.gettext(“WordPress”).”</a> &nbsp;”.

Please let me know if you’ve got any questions or suggestions.

Posted in Wordpress, Zenphoto | Tagged , , , , , , | 5 Comments

I’m Available To Design/Host WordPress Websites

Wordpress Logo

I’ve done web design in various capacities for about 13 years now. Until now, I’ve tended toward custom designs. The reason I’ve done things from scratch is that I can typically design a good user experience and give the customer exactly what they want to see. Recently however, more and more people don’t want just a static set of text and pictures. As the web develops into a more social experience, the customers are interested in being able to change the content themselves so they can keep up with the times. A web site that isn’t easily changed, often ends up being the one that has breaking news about hurricane Katrina or something else that clearly shows it hasn’t been touched recently, and immediately tells the reader that there’s not much to see here.

As a result of this paradigm shift, I’ve come to find that WordPress is an amazing software. With support for integration with the latest social networking platforms such as Facebook and Twitter, it allows a basic site to become a hub of information rather that a pamphlet. The website owner can now use the management interface to write posts, revise entire pages, manage photo galleries, and do things that the average use never thought possible very few years ago. Wordpress is also built in PHP. I love PHP. Love. So nearly anything in the software can be changed to suit the site owner.

All of this is to say that I’m here. You want to share your life or business with people. I can have your website looking spectacular and working beautifully in just a few days. If you’re interested, email me. pcushing@rektproductions.com

Posted in Wordpress | Tagged | Leave a comment

A Little Internet Snow For The Season

I came across an interesting script that adds some winter ambiance to your browsing experience. This little javascript will add a blizzard of snowflakes to any website. Just drag this link to your favorites bar or save it to your favorites. When you reach some website and feel the need for a little snow, click the bookmark. It won’t change pages or steal your soul, just give you some pretty snow.

Let It Snow

p.s. Found that this apparently only works in Chrome and Safari.

Posted in Design | Tagged , | Leave a comment

My First Family Photo Shoot

At about 10:00 am on Thursday my wife called me and asked if I could take some family photos of her sisters’ family that evening. I happened to have a borrowed Nikon D100 and 50mm 1.8 lense. The conditions were not ideal, and the short notice didn’t allow for much planning on my part. I am very knowledgeable in the realm of electronics and photography and know the equipment rather well. The act of actually choosing the setting and posing my subjects however, are relatively new to me.

Lewis Family

Lewis Family

The sun was to set at 5:00 pm and we arrived at the park at nearly 4:30. The light was fading fast but the fast lense made things more simple. The tempature that evening was also a factor. Poor Jaidyn shivered and many of her poses included raised shoulders and scrunched face as she fought to not freeze. I also was having issues with the camera. I started out with the camera set to shoot RAW but it wasn’t working. I switched to JPEG and the camera jumped into action. I would have liked to be able to shoot in RAW but things worked well in JPEG just the same.

Anyway despite all the little problems, we did get some images that they were pleased with. I did learn a few things as well. Due to time constraints, I shot hand held. I would have liked to take the time to use the tripod but the fast lense did allow me to get some reasonable shots without. Shooting JPEG, I also would have liked to adjust my white balance in the camera. I was able to adjust a little in post but I would much rather get it right in camera if possible. The more important lesson though is that I really would like to plan a shoot next time. Possibly scout the location and have more of a plan.

Overall, I’m proud of what we got and hope I get more opportunities in the future. I’ve posted the best of the results in the Photos page. Feel free to check them out and let me know what you think.

Posted in Photography | Tagged , , | Leave a comment