1. Skip to Navigation
  2. Skip to Content
our blog

Posts tagged custom wordpress functions

How to Add Custom Fields to Media in WordPress

Sometimes a WordPress project calls for custom fields on Media. We recently built a custom gallery widget that involved uploading multiple images that would have a caption, a heading, the ability to selectively output the image, and the ability to set the hex code color of the text that was output.

To achieve this, I created a custom field on images that would allow you to input a value to be used as the color for the text and a custom checkbox to indicate to output the image.

There are two steps to this:

  1. Add the custom field to the edit screen,
  2. Process that field when saving / updating the media item.

(more…)

WordPress: How to Exclude Categories From the Archive Widget

Updated: 5/2/2012

We love developing in WordPress. For many of our clients, there is no need to reinvent the wheel and WordPress can be a significant time saver.

WordPress is a very thoroughly developed platform – yet every now and again we bump into desired functionality that isn’t readily available, such as excluding categories from the Archive Widget.

Recently, I developed some code to do just that and thought I would share it.
(more…)

WishList Member: How to Determine if User Has Pay-Per-Post Access to Content

    Updated: 5/14/2012

    There are a lot of good membership plugins out there – we recently finished building a site for a client using WishList Member and ran into a problem when trying to determine if the logged-in user has access to a given piece of Pay-Per-Post content.

    There are a couple of key features that made WL Member ideal for this project:

  1. It allows the purchase of content on either a per-post or subscription basis
  2. It blocks access to Private Media by using htaccess to route the requests through a PHP script

This project called for us to only output links to attachments if the logged-in user had access to the content, and to do so in list views after the Read More tag was output.
(more…)

WordPress: Only Show Authors Their Own Posts and Media in the Admin Area

Updated: 5/13/2012

I’ve helped our clients set up a lot of membership sites; one common request is that members are able to submit articles within WordPress.

Out-of-the-box WordPress can get you pretty far but commonly I run into two roadblocks with the default roles:

  1. The Contributor role doesn’t let Contributors see the Media Library
  2. The Author role lets Authors see everyone’s Media & Posts

While more often than not a plugin is the way to go for a full-on membership site, there’s a really quick fix that will let you assign users to the Author role and be able to hide other’s Media & Posts from them.
(more…)

How To Add A Lightbox To A WordPress Gallery

Updated: 2/29/12

I wanted to setup a simple lightbox photo gallery on a WordPress site (v3.2.1, tested and working on 3.3.1) and, to avoid installing a slew of plugins, I put together a little gallery shortcode function using the built-in WordPress gallery shortcode as my starting point. I’m a big fan of PrettyPhoto, so I modified the output of the gallery shortcode to include a rel= attribute for PrettyPhoto galleries. (more…)

WordPress: How To Change Comment Excerpt Length

I recently needed to output a list of comments and bumped into a little trouble trying to output the comment excerpt. Usually I would use the built-in comment_excerpt() function but I only needed 10 words instead of the 20 that is hard-coded. I put together a little function that I found helpful and thought I would share.

(more…)