sitefinity_logo.jpg
Coding

Something Old and New: Importing WordPress posts into Sitefinity

I can’t take too much credit for this, however, I made enough updates to the library that I felt it warranted a post.

If you’re migrating your blog from WordPress into Sitefinity, I’ve taken an existing tool (major HT to timw255) and modified it. I disabled some features with loading tags/metadata that caused errors. More importantly, I added the ability to have a “default” e-mail address, properly import the full image from the “thumbnail” images that WordPress typically uses, and cleaned up the summary field.

It’s on Github, so as they say, if you don’t like what I did, fork it and improve it yourself! 8^D

You can get the WordPress to Sitefinity tool here.

Continue reading “Something Old and New: Importing WordPress posts into Sitefinity”

wordpress-icon
Coding

How to Embed Full Page iFrames (with busting) in WordPress

Sometimes (at least I did) you need to embed a page (maybe even your own) in “full screen” within your WordPress site. The problem is that by default, you’ll have the header, footer, and any widgets also embedded in the site. This can cause some layout nightmares. However, here’s a trick I have put togetether to render these kind of pages and keep your links working properly.

Continue reading “How to Embed Full Page iFrames (with busting) in WordPress”

Quick Tip
Geekery

Quick Tip: Bulk Edit Post Formats in WordPress

As you may have noticed, I recently merged my photo blog and quote blog here into my main blog. As part of that process, I wanted all of my photos to use the “gallery” post format to take advantage of its display options in the new twenty thirteen theme. When you’re in the main post editor, there’s not way to “bulk edit” post formats. Here’s a “back door” trick on how to get it done. Continue reading “Quick Tip: Bulk Edit Post Formats in WordPress”

Geekery

Quick Tip: Fix old WordPress links with the Redirection plugin and the WayBack Machine

Quick Tip

I’ve been honored to be the webmaster over at Evangelical Outpost for a few years now. The site itself dates back to 2003, but I haven’t been around quite that long. Being that the site has changed owners, webmaster, and formats a couple of times, our permalink structure has changed a couple of times as well. As a result, we’re starting to find some 404 errors coming in from outside links. The old permalink format wasn’t in any form we could recognize (post ID, date code, title, etc.), and I was worried that they might be lost forever. However, thanks to two little features, Redirection and the WayBack Machine, we can now successfully get our links working again! Here’s how. Continue reading “Quick Tip: Fix old WordPress links with the Redirection plugin and the WayBack Machine”

Geekery

Quick Tip: Check Your Mime Types in Internet Explorer and WordPress

This is a rather odd problem I ran into yesterday with a colleague that was worth sharing.

She had installed a WordPress plug-in that allowed you to replace existing files in your media library. This is a great feature for us since we are often updating the same newsletter item and don’t want to remove and re-add the file to the media gallery.

After installation, she went to replace an existing .jpg image and received the following error message:

File type does not meet security guidelines.

Digging into the plug-in, we found the code that generates this message. Continue reading “Quick Tip: Check Your Mime Types in Internet Explorer and WordPress”

Coding

Default Category Images for WordPress

I’ve been working on a news oriented WordPress site lately. One of the nice things with WordPress 2.9 and above was that they created a “thumbnail” feature, also known as “featured image” in 3.0+. With this feature you could display an image  related to the article to help preview it. Most sites you see now use this in conjunction with a “slider” on their home page.

In the site I’m working on, there isn’t a featured image for every single news item available. Sometimes the news item is simply a repeat of a notice from another source. Since the home page of the site looked for an image to display in its list, the page became unattractive since there were a lot of “no image available” boxes scattered on the page:

Site without categories
The site without category images (click for larger view).

The idea then arose about having an icon or default image for each category, and displaying that when an image was not available. Since I’m still honing my WordPress chops, so I needed to develop a solution that didn’t involve creating plugins and wasn’t too deeply embedded within the site that it would make it hard to update down the road. The home page has several widgets that retrieve the featured image in various formats (full, medium, small) so I needed to find a single point of entry in which to return the image, and let the theme do its own resizing.

The first step was to create the category images and place them into a folder called “category-images” under my “wp-content” folder of the site. The key here is to name the images the same as the “nice name” values for each of the categories. This typically means using all lower case and putting a “-“ in place of spaces, such as “prescribed-burns”. This makes it easier to generate the URL to the images in the code.

The next step is to find the code in my theme where the featured images were being retrieved for a given post. This is where you’re going to have to venture out on your own to implement this solution. [Psst, hey WordPress theme developers, this would be a great time to implement this into your theme so no fancy hackery is needed!] After some digging, I found the function that served as the central point for retrieving images that were displayed on the home page widgets:

function get_images($iPostID,$img_size='thumb')

{
   $arrImages =& get_children('order=ASC&orderby=menu_order ID&post_type=attachment&post_mime_type=image&post_parent=' . $iPostID );
   $return_arr = array();

   if($arrImages)
   {
      foreach($arrImages as $key=>$val)
      {
         $id = $val->ID;

         if($img_size == 'large')
         {
            $img_arr = wp_get_attachment_image_src($id,'full');
            $return_arr[] = $img_arr[0];
         }
         elseif($img_size == 'medium')
         {
            $img_arr = wp_get_attachment_image_src($id, 'medium');
            $return_arr[] = $img_arr[0];
         }
         elseif($img_size == 'thumb')
         {
            $img_arr = wp_get_attachment_image_src($id, 'thumbnail');
            $return_arr[] = $img_arr[0];
         }
      }
   }

   return $return_arr;
}

 

The trick to making this work was to add some additional code so that the category image URL would be generated in the even no images where found. The final code looks like this:


function get_images($iPostID,$img_size='thumb')

{
   $arrImages =& get_children('order=ASC&orderby=menu_order ID&post_type=attachment&post_mime_type=image&post_parent=' . $iPostID );
   $return_arr = array();

   if($arrImages)
   {
      foreach($arrImages as $key=>$val)
      {
         $id = $val->ID;

         if($img_size == 'large')
         {
            $img_arr = wp_get_attachment_image_src($id,'full');
            $return_arr[] = $img_arr[0];
         }
         elseif($img_size == 'medium')
         {
            $img_arr = wp_get_attachment_image_src($id, 'medium');
            $return_arr[] = $img_arr[0];
         }
         elseif($img_size == 'thumb')
         {
            $img_arr = wp_get_attachment_image_src($id, 'thumbnail');
            $return_arr[] = $img_arr[0];
         }
      }
   }
   else
   {
      $category = get_the_category($iPostID);

      // if the category has no parents, use its nicename for a proper URL, otherwise use the parent category name (such as fires)
      if ($category[0]->category_parent == 0)
      {
         $return_arr[0] = site_url('/wp-content/category-images/', '') . $category[0]->category_nicename . '.jpg';
      }
      else
      {
         $parent = get_category($category[0]->category_parent);
         $return_arr[0] = site_url('/wp-content/category-images/', '') . $parent->category_nicename . '.jpg';
      }
   }

   return $return_arr;
}

WordPress makes it easy to retrieve category, and even parent category information for the post, and we use as much built in methods as possible so that the URL to the images changes easily if the site changes.

Site with categories.
The site with category images (click for larger view).

I’ve seen a few WordPress plugins to assign images to a category, but they were going to be more trouble than it was worth to integrate it into the current theme. Hopefully this gives you a direction to look at if you need to setup category images for your site, or maybe it’ll inspire a WordPress theme creator out there to build this in to the next theme they create. I’m sure there are plenty of sites that can benefit from this.

Reviews

Review: Head First WordPress

HeadFirstWordPressCover

I’m a seasoned web developer that has been working a little bit with WordPress over the past 6 months. I’ve read books in the “Head First” series before, so when I discovered that there was a WordPress edition, I grabbed it without hesitation. Head First WordPress by Jeff Siarto (HWP) provides an excellent introduction into the WordPress environment.

The book is structured to teach you how WordPress works while simultaneously having you build a couple of fictional WordPress sites. As you’re reading, numerous tips, facts, and humorous asides are annotated throughout the book. This is what makes “Head First” an excellent series of books. It engages your mind while teaching you “tech” things that can be boring to a lot of people.  HWP demonstrates how WordPress can be used for a simple content site, such as a business, or for a magazine/journal type site, which has frequent posts by various authors. While HWP doesn’t go too deep with any particular topic, it does make sure to touch the wide variety of concepts involved with a WordPress site: installation, theming, metadata (categories and tags), creating/editing pages, plugins, users, securing your blog, and more. By the end of the book you will have a good grasp on what WordPress can do for you, a working site that you can work with to customize as you see fit, as well as some additional topics to look into for further study (listed in the “Leftovers” appendix).

While the entire book is geared towards those that have basic web hosting experience, I found the first chapter might be a little intimidating to those users. The chapter outlines a full WordPress install, including FTP transfers, file permissions, and database setups. If you have the “quick install” option available, I suggest you use it. Otherwise, take the time and work through the install, since after that the rest of the book is a lot easier by comparison.

I also want to point out that chapter 5, involving videos and plugins, was my favorite chapter. It did a fantastic job and explaining how plugins and embedded videos work in a WordPress site. The chapter also involved a little bit of customization to the site to easily embed videos and to clean up your home page so that the entire post is not displayed. The author did a great job of explaining these concepts in an easy to understand manner.

Head First WordPress is an excellent book and I highly recommend it to anybody looking to get involved with this popular platform. You can view a preview of the book by going to the O’Reilly site at http://oreilly.com/catalog/9780596806286/.